# View more python learning tutorial on my Youtube and Youku channel!!!

# 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