在R中绘制模型的列车和eval分数

时间:2017-03-16 04:17:29

标签: r plot xgboost

如何在R的地块上绘制火车并测试下面打印的AUC分数(参考图像)?

我正在使用xgb.train模型

train.gdbt <- xgb.train(params=list(objective="binary:logistic", eval_metric="auc", eta=0.5, max_depth=4, subsample=1, colsample_bytree=0.5), data=dtrain, nrounds=500, watchlist=list(eval=dtest, train=dtrain),verbose = 1)

1 个答案:

答案 0 :(得分:0)

您应该从evaluation_log获取xgb,将其修改为长格式,然后以两种颜色绘制:

train.gdbt$evaluation_log %>%
  gather(key=test_or_train, value=AUC, eval_auc, train_auc) %>%
  ggplot(aes(x = iter, y = AUC, group = test_or_train, color = test_or_train)) + 
  geom_line() + 
  theme_bw()

Test & Train AUC plot