我有一个包含 5K 列的数据集,专注于二进制分类。我有超过 60 列。我正在尝试通过 RFECV 方法找到最佳功能。虽然它产生了 30 个最佳特征,但当我在图中绘制时,我只看到 12 个特征。请在下面查看我的代码和绘图
model = RandomForestClassifier(n_estimators=100, random_state=0)
model_b = LinearSVC(class_weight='balanced',max_iter=1000)
# create the RFE model and select 15 attributes
rfe = RFECV(model,step=5,cv=5)
rfe = rfe.fit(X_train_std, y_train)
# summarize the selection of the attributes
feat = rfe.support_
fret = rfe.ranking_
features = X.columns
print(rfe.n_features_) # this returns 30 as output
print(rfe.grid_scores_) this produces the below output
我期待看到 30 个特征的网格得分,在图中,我期待看到 x 轴也有 30 个特征。但它仅显示 12 个功能。同样,如果我的数据集中只有 19 个特征,RFECV 会返回所有 19 个作为最佳特征,这很好。但再次在网格分数中它只显示 4
q1) 这是否意味着超过 12 个特征,模型准确率没有增加?
q2)我假设 grid_scores 只不过是权重/排名,它表示特征对结果的影响。但是我如何获得这 12 个功能的名称呢?
q3)为什么它显示最佳特征数为 30,但网格分数仅显示为 12。
你能帮我解决这些问题吗?
