#调用查看线性回归的几个属性
# Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg
# Youku video tutorial: http://i.youku.com/pythontutorial
"""
Please note, this code is only for python 3+. If you are using python 2+, please modify the code accordingly.
"""
from __future__ import print_function
from sklearn import datasets
from sklearn.linear_model import LinearRegression
loaded_data = datasets.load_boston()
data_X = loaded_data.data
data_y = loaded_data.target
model = LinearRegression()
model.fit(data_X, data_y)
print(model.predict(data_X[:4, :]))
print(model.coef_) #回归系数,即x的系数
print(model.intercept_) #y轴截距,即常数值
print(model.get_params()) #模型参数,例如n_jobs等
print(model.score(data_X, data_y)) # R^2 coefficient of determination 回归模型的分数默认是R^2,当然也可以使用-MSE,即负均方误差