python - 使用超网格搜索和 10 倍 CV 调整参数后,随机森林模型的 AUC 更低

标签 python scikit-learn random-forest auc hyperparameters

我在没有调整超参数的情况下收到的 AUC 值更高。 我使用了相同的训练数据,这里是否缺少一些东西或一些有效的解释。

数据是推文词嵌入的平均值,是使用 50 维推文的预训练 GLoVE 向量计算得出的

无需调整:

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=None,
            oob_score=False, random_state=None, verbose=0,
            warm_start=False)

AUC-0.978

调整:

GridSearchCV(cv=10, error_score='raise-deprecating',
       estimator=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='warn', n_jobs=None,
            oob_score=False, random_state=42, verbose=0, warm_start=False),
       fit_params=None, iid='warn', n_jobs=3,
       param_grid={'max_features': ['auto', 'sqrt', 'log2', None], 'bootstrap': [True, False], 'max_depth': [2, 3, 4], 'criterion': ['gini', 'entropy']},
       pre_dispatch='2*n_jobs', refit=True, return_train_score='warn',
       scoring=None, verbose=0)
print(cv_rf.best_estimator_)
RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
            max_depth=4, 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=10, n_jobs=None,
            oob_score=False, random_state=42, verbose=0, warm_start=False)

AUC-0.883

最佳答案

我预计这有两个可能的原因。

  1. 在前一个模型中,最大深度设置为 None,这意味着节点会扩展,直到所有叶子都是纯的,或者直到所有叶子包含少于 min_samples_split 的样本,而在后一个模型中,max_depth=4,这意味着使模型不太灵活。

建议:您可以增加网格搜索中的最大深度范围

  • 估计器的数量 (n_estimators) 从 100 减少到 10。这使得 Ensemble 模型变得更弱。
  • 建议:增加估计器的数量或调整估计器的数量。

    关于python - 使用超网格搜索和 10 倍 CV 调整参数后,随机森林模型的 AUC 更低,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53708847/

    相关文章:

    python - SVM 和随机森林,召回率 = 0

    r - 为每个因素组添加单独的 vlines 到 ggplot(可变重要性随机森林的点图)

    python - 在 Python 中获取图像对象大小(以字节为单位)- Azure 中的 BadRequest 错误

    python - 逗号分隔的字符串到 Python 2 中的变量

    python - Tkinter 编辑菜单,macos 中的特殊字符选项

    python - 如何将字符串作为 MLP 算法的输入?

    python - 在 DBSCAN 中使用 Mahalanobis 等替代距离度量

    python - 是否可以使用 scikit-learn 而不是二元分类来预测变量(如果可以)而不是如何预测

    python - 如何加速数百万对象的python实例初始化?

    r - 如何导出 R 随机森林模型以在 Excel VBA 中使用而无需 API 调用