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

RandomForest Not Working with Certain Datasets #18

Closed
washcycle opened this issue Feb 1, 2018 · 5 comments
Closed

RandomForest Not Working with Certain Datasets #18

washcycle opened this issue Feb 1, 2018 · 5 comments

Comments

@washcycle
Copy link
Contributor

Using a RandomForest causes an error from the purr package with certain datasets.

It was on one of the RStudio Conference 2018 "Big Data in R" EC2 machines.

library(randomForest)
model <- randomForest(mpg ~ ., data = mtcars)
tidypredict_sql(model, con) # any connection I tried caused the same error

ERROR
Error: .xis empty, and no.init supplied
which comes from the purr package.

@washcycle
Copy link
Contributor Author

washcycle commented Feb 1, 2018

I debugged it down to right here so far...

parsemodel.R

   all_paths <- model_frame %>%
    filter(.data$status == -1) %>%
    pull(.data$rowid) %>%
    map(~get_path(.x, model_frame)) %>%
    bind_rows()

all_paths comes back empty

@washcycle
Copy link
Contributor Author

washcycle commented Feb 1, 2018

When fitting a random forest for regression the status variables doesn't contain 1. It contains -1 and -3 that might be the issue. Can use randomForest::getTree(...) on the model for a regression and classification case to see what I am talking about.

@washcycle
Copy link
Contributor Author

washcycle commented Feb 1, 2018

I think I figured out the issue. The randomForest::getTree has a different criteria for regression problems.

For numerical predictors, data with values of the variable less than or equal to the splitting point go to the left daughter node.

@edgararuiz-zz
Copy link
Contributor

Fixed with #19 - Thanks @washcycle!

@github-actions
Copy link

github-actions bot commented Mar 6, 2021

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants