from sklearn import datasets
from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt #加载数据
loaded_data = datasets.load_boston()
data_X = loaded_data.data
data_Y = loaded_data.target
#是否需要对数据进行拆分
#定义模型
model = LinearRegression()
#训练
model.fit(data_X,data_Y)
#y = 0.1x+0.3
print(model.coef_) #输出斜率0.1
print(model.intercept_) #输出截距0.3
print(model.get_params())
#data_X的预测值,与data_Y(真实值)之间的打分
print(model.score(data_X,data_Y)) #对 Model 用 R^2 的方式进行打分R^2 coefficient of determination