问题描述
我有这段代码呈现“ _xgb.Booster”“ model_fit”对象类。应该,但是我不确定如何在此处为整个可重现的示例代码提供数据!
xgb <- boost_tree(mode = "classification",trees = 100,mtry = 0.7,learn_rate = 0.15,tree_depth = 10,sample_size = 1) %>%
set_engine("xgboost") %>%
fit(Y ~ .,data = train)
如何使用此xgb对象计算升力曲线和十分位升力图?
解决方法
一旦您以示例数据集two_class_example
中的形式获取数据,就可以使用lift_curve()
函数进行计算。然后,您可以使用升力曲线进行可视化。
library(tidymodels)
two_class_lift <- two_class_example %>%
lift_curve(truth,Class1)
two_class_lift %>%
autoplot()
two_class_lift %>%
group_by(.percent_tested = cut_interval(.percent_tested,n = 10)) %>%
summarise(.lift = mean(.lift,na.rm = TRUE)) %>%
ggplot(aes(.percent_tested,.lift)) +
geom_col() +
theme_bw() +
labs(x = "% Tested",y = "Lift")
#> `summarise()` ungrouping output (override with `.groups` argument)
由reprex package(v0.3.0.9001)于2020-08-26创建
如果您需要帮助以获取有关xgboost模型的预测,请check out this article at tidymodels.org
。