线性回归
from sklearn import linear_model
linreg = linear_model.LinearRegression()
from sklearn import datasets
diabetes = datasets.load_diabetes()
diabetes
x_train = diabetes.data[:-20]
x_train
y_train = diabetes.target[:-20]
x_test = diabetes.data[-20:]
y_test = diabetes.target[-20:]
linreg.fit(x_train,y_train)
linreg.coef_ --回归系数B
linreg.predict(x_test)
y_test
linreg.score(x_test,y_test) --方差
结果:0.58507530226905713