赞
踩
```python
'''
案例2:波士顿房价预测
'''
import mglearn
from sklearn.linear_model import LinearRegression#从sklearn里面导入线性回归的算法
from sklearn.model_selection import train_test_split#导入数据集
X,y=mglearn.datasets.load_extended_boston()
X_train,X_test,y_train,y_test=train_test_split(X,y)
lr=LinearRegression().fit(X_train,y_train)
print('训练集的分值:',lr.score(X_train,y_train))
print('测试集的分值:',lr.score(X_test,y_test))
#过拟合:训练集表现得很好,但是测试集表现得不好
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。