Get startedGet started for free

Fit, explore, and evaluate the model

Once you have defined a workflow with a recipe and a model, you can fit the data to the workflow. This is done with the training data set. The trained model is then evaluated using the test set. In this example, the target variable is categorical and you are using a logistic regression model. So you will evaluate the test predictions using the F measure. feature_selection_recipe, lr_model, attrition_wflow, train, and test from the previous exercise are available for your use.

The tidyverse and tidymodels packages have been loaded for you.

This exercise is part of the course

Dimensionality Reduction in R

View Course

Exercise instructions

  • Fit attrition_wflow using the training data.
  • Add the test predictions to the test data with the original Attrition values.
  • Use f_meas() to evaluate the model's performance on the test data.
  • Display the model estimates of attrition_fit.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Fit workflow to train data
attrition_fit <- 
  ___ %>% ___(___ = ___)

# Add the test predictions to the test data
attrition_pred_df <- ___(___, ___) %>% 
  bind_cols(___ %>% select(___))

# Evaluate F score
___(___, ___, ___)

# Display model estimates
___(___)
Edit and Run Code