2017-03-16 74 views
0

如何在R中绘制列车和测试AUC打印在下方的分数(请参阅图像)?在R中绘制模型的火车和评估分数

我使用下面

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) 

回答

0

xgb.train模型,您应该从xgbevaluation_log,其修改为长格式,然后绘制两种颜色:

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

+0

谢谢!这是我想要的:) – Pb89