Split the data
In this exercise, you will split your data into training and test sets using the caret package. In the next set of lessons, you will use the training set to build logistic regression models and use the test set to validate these models.
Este ejercicio forma parte del curso
HR Analytics: Predicting Employee Churn in R
Instrucciones del ejercicio
- Load the
caretpackage. - Set a seed of 567 and create a data partition that divides the dataset
emp_finalinto 70% / 30% train/test sections. - Create the training dataset by selecting the row numbers stored in
index_trainfrom the datasetemp_final. - Assign the remaining observations from
emp_finalto the testing set.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# Load caret
___
# Set seed of 567
___
# Store row numbers for training dataset: index_train
index_train <- ___(emp_final$turnover, p = ___, list = FALSE)
# Create training dataset: train_set
train_set <- emp_final[___, ]
# Create testing dataset: test_set
test_set <- emp_final[___, ]