python - 为什么模型的分数与我的 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 分数与测试数据集的分数不同。为什么会有这样的差异?
解决方案
推荐阅读
- python - 需要解决 if/else 和“and”问题
- python - 嵌套的滚动视图在 MapMarker 的气泡中不起作用
- ios - SwiftUI 自定义步进按钮
- flutter - Flutter:Flavour 是使用相同代码库制作多个应用程序的最佳方式吗?
- acumatica - 我可以将自定义键字段添加到基本 Acumatica 表吗?
- java - 不是抽象的,并且不会覆盖回调中的抽象方法 onError(Exception)
- reactjs - NextJS:将 json 加载到 _app.js vs pages 中的 getInitialProps 并避免重复调用
- r - 降低 R 中 arules 的支持阈值
- ios - React Native 在设备 iOS 崩溃上运行
- r - 调整标题