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

Ranger does not throw an error when predicting with a categorical variable with new/unseen categories #729

Open
D-Maar opened this issue Jul 2, 2024 · 1 comment

Comments

@D-Maar
Copy link

D-Maar commented Jul 2, 2024

Normally an algorithm (e.g. lm) throws an error, if one tries to predict with unseen categories in a categorical variable. ranger just predicts something....
Code:

a<-data.frame(a1=c(1,2,3,4), a2=c("d", "a", "d", "e"))
res<-ranger::ranger(a1~a2,a)
predict(res, data = data.frame(a1=c(1,2,3,4), a2=c("d", "a", "f", "f")))$prediction
@mnwright
Copy link
Member

mnwright commented Jul 3, 2024

I agree, this should give an error (or maybe a warning and document what happens with the new category).

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

2 participants