【问题标题】:Used SequentialFeatureSelector but does not improve the model accuracy使用了 SequentialFeatureSelector 但没有提高模型精度
【发布时间】: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


    【解决方案1】:

    随机森林分类器不只是随机化特征,它们还会随机化这些特征的分割,所以即使你的特征保持不变,你的特征分割每次都是随机生成的,这可能会引入一些差异该模型。对于平均方差更小的更正则化的模型,我推荐Gradient Boosted Model,或者更好的是XGBoost

    随机森林为模型增加了额外的随机性,同时增长 树。而不是搜索最重要的特征,而 分裂一个节点,它在随机数中搜索最好的特征 特征的子集。这导致了广泛的多样性,通常 产生更好的模型。

    因此,在随机森林中,只有特征的随机子集是 分割节点的算法考虑了这一点。 你 甚至可以通过额外使用随机数使树更加随机 每个特征的阈值,而不是寻找最好的 可能的阈值(就像正常的决策树一样)。

    来源:https://towardsdatascience.com/the-random-forest-algorithm-d457d499ffcd

    【讨论】:

      猜你喜欢
      • 2019-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-15
      • 2020-08-06
      • 2017-08-31
      • 1970-01-01
      相关资源
      最近更新 更多