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

Current use of OOB prediction in pmm #14

Closed
stephematician opened this issue Aug 4, 2018 · 1 comment
Closed

Current use of OOB prediction in pmm #14

stephematician opened this issue Aug 4, 2018 · 1 comment

Comments

@stephematician
Copy link

I was just having a cursory look at the missRanger algorithm, and I noticed this:

    data[v.na, v] <- if (pmm.k) pmm(xtrain = fit$predictions, 
                                    xtest = pred, 
                                    ytrain = data[[v]][!v.na], 
                                    k = pmm.k) else pred

The value of fit$predictions is the out-of-bag prediction - not the prediction of the forest. Is this the intended behaviour? The prediction of the random forest (in its entirety) can only be found via predict(fit, data=data[!v.na, union(v, completed))$predictions. Unfortunately, prediction is somewhat slow in ranger - if you have good reasons to use the out-of-bag predictions rather than the fitted forest predictions, then that'd be great.

@mayer79
Copy link
Owner

mayer79 commented Aug 4, 2018

Thanks for looking into the code. It is indeed intended to use OOB predictions since insample predictions of random forests typically are badly overfitted and too close to the observed values:

library(ranger)

fit <- ranger(Sepal.Length ~ ., data = iris) # OOB R-squared: 0.8395822
insample_residuals <- iris$Sepal.Length - predict(fit, iris)$predictions
1 - var(insample_residuals) / var(iris$Sepal.Length) # Insample R-squared: 0.9546763

@mayer79 mayer79 closed this as completed Aug 20, 2018
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