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

SUPERLEARNER! #14

Open
grwhumphries opened this issue Sep 6, 2019 · 0 comments
Open

SUPERLEARNER! #14

grwhumphries opened this issue Sep 6, 2019 · 0 comments

Comments

@grwhumphries
Copy link

grwhumphries commented Sep 6, 2019

Highly recommending this great new package:
https://cran.r-project.org/web/packages/SuperLearner/vignettes/Guide-to-SuperLearner.html!! You can run all your great models in one beautiful line of code. Assuming you have a training dataset that looks like this:

# Reduce to a dataset of 150 observations to speed up model fitting.
train_obs = sample(nrow(data), 150)

# X is our training sample.
x_train = data[train_obs, ]

# Create a holdout set for evaluating model performance.
# Note: cross-validation is even better than a single holdout sample.
x_holdout = data[-train_obs, ]

# Create a binary outcome variable: towns in which median home value is > 22,000.
outcome_bin = as.numeric(outcome > 22)

y_train = outcome_bin[train_obs]
y_holdout = outcome_bin[-train_obs]

Then all you have to do to run a simple model is:

sl = SuperLearner(Y = y_train, X = x_train, family = binomial(),method='method.AUC',
                  SL.library = c("SL.mean", "SL.glmnet","SL.ranger"),)
sl

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