python-3.x - 如何减少 xgboost 中的误报?
问题描述
我的数据集平均分为 0 和 1 个分类器。总共 100,000 个数据点,其中 50,000 个被归类为 0,另外 50,000 个被归类为 1。我进行了 80/20 拆分来训练/测试数据并返回 98% 的准确度分数。然而,在查看混淆矩阵时,我有很多误报。一般来说,我是 xgboost 和决策树的新手。我可以更改哪些设置XGBClassifier
以减少误报的数量,甚至有可能吗?谢谢你。
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=.2, random_state=0, stratify=y) # 80% training and 20% test
model = xgb.XGBClassifier(base_score=0.5, booster='gbtree', colsample_bylevel=1,
colsample_bynode=1, colsample_bytree=1, gamma=0, gpu_id=-1,
importance_type='gain', interaction_constraints='',
learning_rate=0.1, max_delta_step=0, max_depth=9,
min_child_weight=1, missing=None, monotone_constraints='()',
n_estimators=180, n_jobs=4, num_parallel_tree=1, random_state=0,
reg_alpha=0, reg_lambda=1, scale_pos_weight=1, subsample=1,
tree_method='exact', use_label_encoder=False,
validate_parameters=1, verbosity=None)
model.fit(X_train,
y_train,
verbose = True,
early_stopping_rounds=10,
eval_metric = "aucpr",
eval_set = [(X_test, y_test)])
plot_confusion_matrix(model,
X_test,
y_test,
values_format='d',
display_labels=['Old Forests', 'Not Old Forests'])
解决方案
是 如果您正在寻找一个简单的修复方法,您可以降低 scale_pos_weight 的值。即使您的数据集是平衡的,这也会降低误报率。
要获得更强大的修复,您将需要运行超参数调整搜索。特别是你应该尝试不同的值:scale_pos_weight、alpha、lambda、gamma 和 min_child_weight。因为它们对模型的保守程度影响最大。
推荐阅读
- javascript - IOS 13.3 - 单击后退按钮时刷新页面
- mysql - 当我从转储 Mysql 中恢复时会发生什么
- sql - 在 SQL 中合并两个表,用一个公共列
- api - 通过 Ansible 一次 api 调用同时更新 100 个值
- c# - SeriLog Formatter:如何在json配置文件中传递formatter参数
- scala - Scala spark有什么办法可以将这个数据框转换成这个?
- sonarqube - SonarQube 7.9.1 LTS 未启动:无法创建共享内存
- ios - 为什么 Xcode 11 颜色的属性选择器在缩略图中有 2 种不同的颜色?
- node.js - 如何在nodejs中获取文件大小作为异步等待?
- vue.js - vue I18n:如何制作漂亮的更改语言的下拉列表