Task01:线性回归
模型建立:线性回归原理、线性回归模型学习策略:线性回归损失函数、代价函数、目标函数算法求解:梯度下降法、牛顿法、拟牛顿法等线性回归的评估指标sklearn参数详解练习部分
基于线性回归的房价预测问题利用sklearn解决回归问题sklearn.linear_model.LinearRegressionps:很多东西还没有时间学到。只把自己理解的东西写了一些。
1.线性回归算法的三种评测方法:1.均方误差MSE
1 m ∑ i = 1 m ( y t e s t ( i ) − y ^ t e s t ( i ) ) 2 = M S E t e s t frac{1}{m}sum_{i=1}^m (y_{test}^{(i)}-hat{y}_{test}^{(i)})^2 =MSE_{test} m1i=1∑m(ytest(i)−y^test(i))2=MSEtest
2.均方根误差RMSE
1 m ∑ i = 1 m ( y t e s t ( i ) − y ^ t e s t ( i ) ) 2 = M S E t e s t sqrt{frac{1}{m}sum_{i=1}^m (y_{test}^{(i)}-hat{y}_{test}^{(i)})^2} =sqrt{MSE_{test}} m1i=1∑m(ytest(i)−y^test(i))2
=MSEtest
3.平均绝对误差MAE
M A E = 1 m ∑ i = 1 m ∣ y t e s t ( i ) − y ^ t e s t ( i ) ∣ MAE=frac{1}{m}sum_{i=1}^mvert y_{test}^{(i)}-hat{y}_{test}^{(i)}vert MAE=m1i=1∑m∣ytest(i)−y^test(i)∣
R 2 = 1 − s s r e s i d u a l s s t o t a l R^2 = 1-frac{ss_{residual}}{ss_{total}} R2=1−sstotalssresidual
R^2是最好的衡量线性回归法的指标。
1.R^2<=1
2.R^2越大越好
3.当我们的模型等于基准模型时,R^2=0
4.如果R^2<0,说明我们学习到的模型还不如基准模型。此时,很有可能我们的数据不存在任何线性关系。