【发布时间】:2019-06-22 17:53:42
【问题描述】:
我正在选择用于构建客户流失预测模型的特征。使用 RandomForestClassifier,我得到了 0.9517 的准确度,它显示了 16 个选择作为其中一部分的特征。
但是,如果我使用 RandomForestClassifier 分别使用相同的 16 个特征列表拟合模型,它显示的准确度得分为 0.8714,为什么尽管我使用了由 SequentialFeatureSelector 选择的相同特征列表,但准确度得分却存在巨大差异?
[2019-01-28 17:51:16] 特点:16/16——得分: 0.9517879681082387[Parallel(n_jobs=1)]:完成 1 出 1 |已用时间:3.6s 剩余时间:0.0s
rand_forest = RandomForestClassifier(bootstrap=True,
class_weight=None, criterion='gini',
max_depth=None, max_features='auto',
max_leaf_nodes=None,
min_impurity_decrease=0.0, min_impurity_split=None,
min_samples_leaf=1, min_samples_split=2,
min_weight_fraction_leaf=0.0, n_estimators=100, n_jobs=1,
oob_score=False, random_state=None, verbose=0,
warm_start=False)
SequentialFeatureSelector(clone_estimator=True, cv=0,
estimator=rand_forest,
floating=False, forward=True, k_features=16, n_jobs=1,
pre_dispatch='2*n_jobs', scoring='accuracy', verbose=2)
xtr, xtst, ytr, ytst = train_test_split(x, y, random_state=5, test_size=0.2)
rfst = RandomForestClassifier(n_estimators=100)
rfstmodel = rfst.fit(xtr, ytr)
rfstmodel.score(xtst, ytst)
>>> 0.8714975845410629
【问题讨论】:
标签: python random-forest feature-selection