Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure 5.7 #64

Open
rubrobledo opened this issue Dec 29, 2022 · 0 comments
Open

Figure 5.7 #64

rubrobledo opened this issue Dec 29, 2022 · 0 comments

Comments

@rubrobledo
Copy link

The code proposed to reproduce Figure 5.7 (pag.118) does not seem to work correctly.

pred.fun <- function(object, newdata) {
Yes <- mean(predict(object, newdata, type = "prob")$Yes)
as.data.frame(Yes)}
p1 <- pdp::partial(cv_model3, pred.var = "OverTime", pred.fun=pred.fun) %>%
autoplot(rug = TRUE) + ylim(c(0, 1))
Error in ggplot_two_predictor_pdp(object = object, rug = rug, smooth = smooth, :
The training data must be supplied for rug display.

It is possible that the proposed prediction function does not generate an acceptable data frame for the "partial" function, since when executing:

pdp::partial(cv_model3, pred.var = "OverTime", pred.fun=pred.fun)
you get the following:
OverTime yhat.Yes yhat.Yes
1 No 0.1044187 0.31364
2 Yes 0.1044187 0.31364

What can I be doing wrong or what should be corrected in the code?
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant