НачатьНачать бесплатно

Data resampling

The first step in a machine learning project is to create training and test datasets for model fitting and evaluation. The test dataset provides an estimate of how your model will perform on new data and helps to guard against overfitting.

You will be working with the telecom_df dataset which contains information on customers of a telecommunications company. The outcome variable is canceled_service and it records whether a customer canceled their contract with the company. The predictor variables contain information about customers' cell phone and Internet usage as well as their contract type and monthly charges.

The telecom_df tibble has been loaded into your session.

Это упражнение является частью курса

Modeling with tidymodels in R

Посмотреть курс

Инструкции к упражнению

  • Create an rsample object, telecom_split, that contains the instructions for randomly splitting the telecom_df data into training and test datasets.
    • Allocate 75% of the data into training and stratify the results by canceled_service.
  • Pass the telecom_split object to the appropriate rsample functions to create the training and test datasets.
  • Check the number of rows in each datasets by passing them to the nrow() function.

Интерактивное практическое упражнение

Попробуйте выполнить это упражнение, дополнив этот пример кода.

# Create data split object
telecom_split <- ___(___, prop = ___,
                     strata = ___)

# Create the training data
telecom_training <- ___ %>% 
  ___

# Create the test data
telecom_test <- ___ %>% 
  ___

# Check the number of rows
nrow(___)
nrow(___)
Редактировать и запускать код