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

no applicable method for 'predict' applied to an object of class "c('randomForest.formula', 'randomForest')" #559

Closed
boral opened this issue Nov 15, 2023 · 1 comment
Labels
looking for help looking for help R 🐳 Related to R

Comments

@boral
Copy link

boral commented Nov 15, 2023

Trying to replicate the example provided here : https://ema.drwhy.ai/breakDown.html

Facing the following error : no applicable method for 'predict' applied to an object of class "c('randomForest.formula', 'randomForest')"

Code

rm(list = ls() )

titanic_imputed <- archivist::aread("pbiecek/models/27e5c")
titanic_rf <- archivist:: aread("pbiecek/models/4e0fc")
(henry <- archivist::aread("pbiecek/models/a6538"))

explain_rf <- DALEX::explain(model = titanic_rf,  
                             data = titanic_imputed[, -9],
                             y = titanic_imputed$survived == "yes", 
                             label = "Random Forest")

bd_rf <- predict_parts(explainer = explain_rf,
                       new_observation = henry,
                       type = "break_down")
@maksymiuks maksymiuks added R 🐳 Related to R looking for help looking for help labels Nov 15, 2023
@maksymiuks
Copy link
Member

Hi @boral

It looks like you don't have the randomForest R package installed. Try installing it from CRAN, and then load it to register S3 methods. One way of loading the package is simply attaching it but running library("randomForest"). Then, the above code should work without any problems.

@boral boral closed this as completed Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
looking for help looking for help R 🐳 Related to R
Projects
None yet
Development

No branches or pull requests

2 participants