from sklearn import linear_model
import numpy as np
model_reg = linear_model.LinearRegression()
# 训练数据集
data=[[1,2],[4,8]]
X_train = np.array(data)[:,0].reshape(-1,1)
y_train = np.array(data)[:,1].reshape(-1,1)
# 训练回归模型
model_reg.fit(X_train, y_train)
# 测试数据
test_data_X = np.array([10,12]).reshape(-1,1)
test_data_y = model_reg.predict(test_data_X)
print(test_data_y)