一、挖掘目标

1)分析、识别影响房屋价格的关键特征;2)预测房屋价格。

二、分析方法

经过探索分析发现该案例特征存在①异常值问题②多重共线性问题,通过尝试删除异常值、或不重要特征或有共线性特征来提高R方。本次练习共应用了线性回归、岭回归、Lasso回归算法,并最终确定用岭回归算法建立模型并预测。

三、总结

通过本次练习,系统掌握了线性回归的分析步骤和流程,对线性回归模型有了进一步的认识。

附:练习代码及关键输出

(一)导入数据

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

(二)探索数据

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

(三)数据预处理

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

(四)多重共线性验证

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

(五)建模

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

(六)预测

①预测

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

②预测

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

Python算法练习(八)// 算法:线性回归,数据集:fetch_california_housing

相关文章:

  • 2021-11-13
  • 2022-12-23
  • 2021-09-23
  • 2021-09-14
  • 2021-08-06
  • 2021-04-10
  • 2021-11-29
猜你喜欢
  • 2021-12-05
  • 2022-12-23
  • 2021-07-08
  • 2021-11-21
相关资源
相似解决方案