scikit-learn 线性回归算法库小结

In [1]: from sklearn.datasets import load_boston
     ...: from sklearn import linear_model
     ...: from sklearn.cross_validation import train_test_split
     ...: from string import ascii_uppercase
     ...: import warnings
     ...: warnings.filterwarnings('ignore')
     ...: L = list(filter(lambda x: x.startswith(tuple(ascii_uppercase)), dir(linear_model)))


In [2]: boston = load_boston()
In [3]: x2, y2 = boston.data, boston.target
In [4]: xTrain, yTrain, xtest, ytest = train_test_split(x2, y2)
In [5]: for model in L:
     ...:     try:
     ...:         model2 = getattr(linear_model, model)()
     ...:         model2.fit(xTrain, xtest)
     ...:         print ('{:>30} : score  : {:<20}'.format(model, model2.score(yTrain, ytest)))
     ...:     except:pass
     ...:     
                 ARDRegression : score  : 0.7088646320904151  
                 BayesianRidge : score  : 0.7045141566856377  
                    ElasticNet : score  : 0.6603516140711009  
                  ElasticNetCV : score  : 0.6465871598904319  
                HuberRegressor : score  : 0.5565922777934672  
                          Lars : score  : 0.7080364004790854  
                        LarsCV : score  : 0.7045934873727482  
                         Lasso : score  : 0.6573343838206422  
                       LassoCV : score  : 0.6772188189534654  
                     LassoLars : score  : -0.000989139814329132
                   LassoLarsCV : score  : 0.7230538108571827  
                   LassoLarsIC : score  : 0.7119005222385881  
              LinearRegression : score  : 0.7089655189671733  
     OrthogonalMatchingPursuit : score  : 0.504333961343415   
   OrthogonalMatchingPursuitCV : score  : 0.6890447027265303  
    PassiveAggressiveRegressor : score  : 0.20510044622867962 
               RANSACRegressor : score  : 0.6737791511350468  
                         Ridge : score  : 0.712458967028207   
                       RidgeCV : score  : 0.7101637255944955  
                  SGDRegressor : score  : -5.380985022454105e+25
             TheilSenRegressor : score  : 0.6965646966699823  

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

转载:scikit-learn 线性回归算法库小结

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值