data.csv
from sklearn.model_selection import train_test_split
import numpy as np
from sklearn import datasets,linear_model
import pandas as pd
data = pd.read_csv("data.csv“)
y = data.iloc[:,2]
x = data.iloc[:, 3:5]
# 训练数据
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size = 0.25, random_state = 1)
regr = linear_model.LinearRegression()
regr.fit(x_train,y_train)
print('coefficients(b1,b2...):',regr.coef_)
print('intercept(b0):',regr.intercept_)
# 预测数据
y_pred = regr.predict(x_test)
# 查看模型得分
regr.score(x_test, y_test)