利用波士顿房价解释线性回归
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
import numpy as np
from sklearn import datasets
from sklearn.model_selection import train_test_split
# 波士顿房价
boston=datasets.load_boston()
# X=np.linspace(0,10,50).reshape(-1,1)
# y=np.random.randint(2,8,size=1)*X
# lr=LinearRegression()
# lr.fit(X,y)
# # coeficient 效率,斜率
# print(lr.coef_)
# # 线性代数中的矩阵运算,求解最小值(最小二乘法)
# np.linspace.inv(X.T.dot(X)).dot(X.T).dot(y)
X=boston['data'