我正在尝试为我的数据集进行特征选择阶段。
我是 ML 的新手。我有大约 60 列,正在尝试选择前 15 个功能。我开始了解 RFECV,为此我编写了如下所示的代码。我知道它n_features存在,RFE但它缺少RFECV. 有没有其他方法来分配number of features to select?
model = RandomForestClassifier(n_estimators=100, random_state=0)
# create the RFE model and select 15 attributes
rfe = RFECV(model,step=5, cv=5,min_features_to_select = 15,max_features_to_select = 15) # this doesn't work. `n_features=15` also doesn't work
rfe = rfe.fit(X_train_std, y_train)
# summarize the selection of the attributes
feat = rfe.support_
fret = rfe.ranking_
features = X.columns
print(features[feat].tolist())
有人可以帮我只获得前 15 个功能吗?我在哪里可以配置n_features参数?
目前它显示了 30 多个功能。我真的不知道它是如何或从哪里得到它的数字(30)的?