首页 > 解决方案 > 为什么模型的分数与我的 XGBoost 模型中的 f1 分数不同

问题描述

我在 python 3 中使用 XGBoost 库制作了一个梯度提升模型。该模型是针对特定电信数据集的分类模型。

结果如下。

searching domain
{"learning_rate"    : [0.05, 0.10],
 "max_depth"        : [ 5, 6, 8],
 "min_child_weight" : [ 1, 3, 5],
 "gamma"            : [0.1],
 "colsample_bytree" : [ 0.3, 0.4 ],
 "n_estimators"     : [10, 9],
 "objective"        : ['binary:logistic'],
 "eval_metric"      : ['error']}

Best score: 0.846148908841385
Best arguments: {'colsample_bytree': 0.4, 'eval_metric': 'error', 'gamma': 0.1, 'learning_rate': 0.05, 'max_depth': 6, 'min_child_weight': 1, 'n_estimators': 10, 'objective': 'binary:logistic'}

score on train data: 0.8805998860989313
score on test data: 0.8364520807988984

confusion matrix
[[1417  107]
 [ 329  260]]

 y_test to y_pred roc_crv
               precision    recall  f1-score   support

           0       0.81      0.93      0.87      1524
           1       0.71      0.44      0.54       589

    accuracy                           0.79      2113
   macro avg       0.76      0.69      0.71      2113
weighted avg       0.78      0.79      0.78      2113

img


但我不明白为什么 f1 分数与测试数据集的分数不同。为什么会有这样的差异?

标签: pythonclassificationxgboost

解决方案


推荐阅读