简体   繁体   中英

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. I have tried this using the pdp library:

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.

Although the model is functional and I managed to plot the breakdown plots using modelstudio. 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. za1 is a numerical variable.

You need to specify the type. If ICP is continuous, try

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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