简体   繁体   English

部分依赖/ALE/ICE 在 r 中绘制 XgBoost

[英]Partial dependence/ALE/ICE plots XgBoost in r

I am trying to plot pdp, ale and ICE plots for a regression Xgboost model in r built using the Xgboost library.我正在尝试使用 Xgboost 库构建的 r 中的 plot pdp、ale 和 ICE 绘制回归 Xgboost model。 I have tried this using the pdp library:我已经尝试过使用 pdp 库:

library(pdp)

    xv <- data.matrix(subset(data, select = -ICP))  # training features
    p1xv <- partial(xgbc, pred.var = "za1", ice = TRUE, center = TRUE, 
    plot = TRUE, rug = TRUE, alpha = 0.1, plot.engine = "ggplot2", train = xv)

I am getting the following error:我收到以下错误:

Error in partial.default(xgbc, pred.var = "za1", ice = TRUE, center = TRUE, : Partial dependence values are currently only available for classification and regression problems. partial.default(xgbc, pred.var = "za1", ice = TRUE, center = TRUE, : 部分依赖值目前仅可用于分类和回归问题。

Although the model is functional and I managed to plot the breakdown plots using modelstudio.尽管 model 可以正常工作,但我使用 modelstudio 设法对 plot 进行了分解图。 Any ideas on the reason for the error?关于错误原因的任何想法? Is there a parameter in the model that needs to be defined specifically to generate these plots. model 中是否有需要专门定义以生成这些图的参数。 za1 is a numerical variable. za1 是一个数值变量。

You need to specify the type.您需要指定类型。 If ICP is continuous, try如果 ICP 是连续的,请尝试

p1xv <- partial(xgbc, pred.var = "za1", ice = TRUE, center = TRUE, plot = TRUE, rug = TRUE, alpha = 0.1, plot.engine = "ggplot2", train = xv, type = "regression")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM