Partial dependence plot appears in the opposite way
mcchiu opened this issue · 5 comments
mcchiu commented
I build the xgboost model.
The partial dependence plot (red line) appears in the opposite way.
Could you please help out?
set.seed(1278)
xgb_f <- xgboost(data = data,
label = type,
eta = 0.1,
max_depth = 15,
nround = 35,
subsample = 0.5,
colsample_bytree = 0.5,
objective = "reg:squarederror",
nthread = 4,
verbose = FALSE
)
xgb_f %>%
partial(pred.var = "airTEMP", grid.resolution = 100,
train = data, ice = TRUE, type = "regression") %>%
autoplot(rug = TRUE, train = data, alpha = .1, center = TRUE)
bgreenwell commented
@mcchiu do you have the code to reproduce data and type?
mcchiu commented
@bgreenwell
Here is the code to reproduce data and type.
dataAll <- read.csv("rawdatasub1.csv")
type <- data.matrix(dataAll$aquarticflux)
data <- data.matrix(dataAll[,! names(dataAll) %in% "aquarticflux"])
bgreenwell commented
Thanks @mcchiu, I'll take a look. For now, plotPartial(airTEMP, alpha = 0.1, center = TRUE)
(which uses lattice) seems to work fine.
bgreenwell commented
Still not sure what the exact issue is, but here's a quick fix if you still want to use ggplot2
d <- pdp:::center_ice_curves.ice(airTEMP) # center manually
ggplot(d, aes(airTEMP, yhat, group = yhat.id)) +
geom_line(alpha = 0.1) +
geom_line(data = pdp:::average_ice_curves.ice(d), color = "red",
aes(airTEMP, yhat), inherit.aes = FALSE)
mcchiu commented
@bgreenwell Thanks for the help. Either works. I look forward to your new release.