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

Workflows library #23

Open
wdoyle42 opened this issue Jan 22, 2020 · 0 comments
Open

Workflows library #23

wdoyle42 opened this issue Jan 22, 2020 · 0 comments
Labels

Comments

@wdoyle42
Copy link
Collaborator

wdoyle42 commented Jan 22, 2020

Workflows makes a huge difference:

## Set recipe
grad_rec<-recipe(formula=ba_complete_formula,data=df_a)%>%
        ## NB: this is dicey and should be improved, but it's a
        ## start; using K nearest neighbors to impute.
        step_knnimpute(all_predictors()) %>%
        ## convert factors to dummy
        step_dummy(dplyr::one_of(likely_factors)) %>%
        ## center predictors
        step_center(all_predictors())  %>%
        ## rescale all predictors
        step_scale(all_predictors())

## Set Model
grad_mod<-
  logistic_reg()%>%
  set_engine("glm")

##Set Workflow 
grad_wfl<-
  workflow()%>%
  add_recipe(grad_rec)%>%
  add_model(grad_mod)

Then running the model across a resampled dataset looks like this:

  grade_res<-fit_resamples(grad_wfl,
                resamples=validation_data,
                control=control_resamples(save_pred=TRUE))

Way better than the first way I did it. I think this obviates the need for anything but various models

@wdoyle42 wdoyle42 reopened this Jan 22, 2020
@wdoyle42 wdoyle42 added the FYI label Jan 23, 2020
This was referenced Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant