Python SKF给出列表列表
该计划的目标是通过github回购协议中的许多功能来预测星星的数量 这很好,精度很高,现在我想要的是找到这些特征的特征重要性。我看到coef_u在这方面被大量使用,因为它似乎是一个简单的解决方案 我遇到的问题是coef_uu返回一个列表3x10(10是如下所示的功能数量) 我的问题是,为什么会返回3个不同的列表Python SKF给出列表列表,python,scikit-learn,logistic-regression,Python,Scikit Learn,Logistic Regression,该计划的目标是通过github回购协议中的许多功能来预测星星的数量 这很好,精度很高,现在我想要的是找到这些特征的特征重要性。我看到coef_u在这方面被大量使用,因为它似乎是一个简单的解决方案 我遇到的问题是coef_uu返回一个列表3x10(10是如下所示的功能数量) 我的问题是,为什么会返回3个不同的列表 model = LogisticRegression(solver='liblinear', multi_class='ovr', max_iter=1000) model.fit(X_
model = LogisticRegression(solver='liblinear', multi_class='ovr', max_iter=1000)
model.fit(X_train, Y_train)
作为参考,X_系列为5000x10型,Y_系列为5000x1型
功能
被预测的是一列overwentyfivepercent
pd.DataFrame(model.coef_[0], dfCopy.columns, columns=['coefficient'])
name -0.145628
pushed_at -0.052148
updated_at 1.100940
size -0.006121
has_downloads -0.084252
watchers 16.291155
open_issues -0.029331
forks 0.901897
created_at -0.020457
archived -0.081115
importance = model.coef_
[[-1.40184146e-01 -4.84178243e-02 1.15512242e+00 -3.28964506e-02
-6.26576200e-02 1.62359829e+01 -1.15330585e-02 8.69313030e-01
-1.98661071e-02 -6.42662896e-02]
[ 1.94129222e-02 -7.45851193e-03 2.73873650e-01 -1.36233707e-02
2.02166947e-02 -3.34864880e+00 -2.68649386e-02 -6.72242010e-02
-2.37043006e-02 -7.86084337e-03]
[ 1.99005178e-02 1.94243453e-02 -1.27329344e-01 5.62809134e-02
-1.26026931e-02 -2.04670813e+01 -9.90259533e-02 -2.51335991e+00
-3.91467209e-02 3.87512897e-02]]
结果列表
pd.DataFrame(model.coef_[0], dfCopy.columns, columns=['coefficient'])
name -0.145628
pushed_at -0.052148
updated_at 1.100940
size -0.006121
has_downloads -0.084252
watchers 16.291155
open_issues -0.029331
forks 0.901897
created_at -0.020457
archived -0.081115
importance = model.coef_
[[-1.40184146e-01 -4.84178243e-02 1.15512242e+00 -3.28964506e-02
-6.26576200e-02 1.62359829e+01 -1.15330585e-02 8.69313030e-01
-1.98661071e-02 -6.42662896e-02]
[ 1.94129222e-02 -7.45851193e-03 2.73873650e-01 -1.36233707e-02
2.02166947e-02 -3.34864880e+00 -2.68649386e-02 -6.72242010e-02
-2.37043006e-02 -7.86084337e-03]
[ 1.99005178e-02 1.94243453e-02 -1.27329344e-01 5.62809134e-02
-1.26026931e-02 -2.04670813e+01 -9.90259533e-02 -2.51335991e+00
-3.91467209e-02 3.87512897e-02]]
从中,coefs\uz
具有形状(n\u类,n\u特性)
,这表明您已以某种方式将模型调整为具有三个类。检查Y\u列
或model.classes
中的唯一值