【发布时间】:2018-12-16 13:12:33
【问题描述】:
我正在使用随机森林进行特征选择(首先是 100 个最重要的特征)。
这是我正在使用的代码;
RandomForest_model = RandomForestRegressor(n_estimators=300,n_jobs=-1)
RandomForest_model.fit(train_x,train_y)
RandomForest_model.score(train_x,train_y)
indices = RandomForest_model.feature_importances_.argsort()[:100]
train_100_x= train.iloc[:,indices]
test_100_y = test_100_y.iloc[:,indices]
我的问题是我的 train 和 test 列不匹配。
看图:
训练和测试中第一列的图片:
我做错了什么还是更有效的方法?
这是我从中下载训练和测试数据集的kaggle competition。
【问题讨论】:
-
能否请您发布整个代码,包括用于训练和测试的拆分
-
在这个阶段我还没有拆分它。它来自 Kaggle 的一场比赛,我在那里分别下载了测试和训练数据集。我正在考虑在训练和测试中进行选择。
标签: python pandas machine-learning scikit-learn random-forest