【发布时间】:2021-06-14 13:43:49
【问题描述】:
我正在尝试使用 RFECV 来选择不同机器学习算法的特征,但耗时太长。代码运行了几个小时并且没有给出任何输出..
这是我的代码:
# Feature selection by RFECV
from sklearn.feature_selection import RFECV
from sklearn.svm import SVR
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import AdaBoostClassifier
from sklearn.ensemble import RandomForestClassifier
estimator = AdaBoostClassifier(random_state=0)
selector = RFECV(estimator, step=1, cv=5)
selector = selector.fit(features, popular)
selector.ranking_
#estimator_LR = LogisticRegression(random_state=0)
estimator_LR = LogisticRegression(C=1.0, tol=0.01, random_state=0, max_iter=10000)
selector_LR = RFECV(estimator_LR, step=1, cv=5)
selector_LR = selector_LR.fit(features, popular)
selector_LR.ranking_
estimator_RF = RandomForestClassifier(random_state=0)
selector_RF = RFECV(estimator_RF, step=1, cv=5)
selector_RF = selector_RF.fit(features, popular)
selector_RF.ranking_
我尝试一次运行 1 行代码,但代码卡在所有三个分类器的 selector.fit 行上。
selector_RF = selector_RF.fit(features, popular)
我的数据集包含近 35000 个实例和 60 个属性。
【问题讨论】:
-
你说你的代码卡住了,你得到什么样的错误?
-
我的意思是代码处于运行模式,没有给出任何输出。
标签: python machine-learning scikit-learn