ValueError:使用RFE时,Pandas Dataframe中的未知标签类型

时间:2019-03-29 15:53:57

标签: python pandas

我目前正在使用RFE来找出世界幸福指数的3个最重要的预测指标(即CSV数据集中的“生命阶梯”),但无法使RFE代码正常工作。

# Feature Extraction with RFE
from sklearn.feature_selection import RFE
from sklearn.linear_model import LogisticRegression
#Load Data
array = year05.values
print(type(array))
X = array[:,3:8]
print(type(X))
Y = array[:,2]
print(type(Y))
#Feature Extraction
model = LogisticRegression()
rfe = RFE(model, 2)
fit = rfe.fit(X, Y)
print("Num Features: %d") % fit.n_features_
print("Selected Features: %s") % fit.support_
print("Feature Ranking: %s") % fit.ranking_

实际数据集如下所示:     [CSV数据示例] [1]

  [1]: https://i.stack.imgur.com/Ha4Xp.jpg

0 个答案:

没有答案