Comparison of Employee attrition models

In this exercise, your task is to compare the balanced and imbalanced (default) models using the pruned tree (max_depth=7). The imbalanced model is already done using recall and ROC/AUC scores. Complete the same steps for the balanced model.

  • The variables features_train, target_train, features_test and target_test are already available in your workspace.
  • An imbalanced model has already been fit for you and, and its predictions saved as prediction.
  • The functions recall_score() and roc_auc_score() have been imported for you.

This exercise is part of the course

HR Analytics: Predicting Employee Churn in Python

View Course

Exercise instructions

  • Initialize the balanced model, setting its maximum depth to 7, and its seed to 42.
  • Fit it to the training component using the training set.
  • Make predictions using the testing set.
  • Print the recall score and ROC/AUC score.

Hands-on interactive exercise

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

# Print the recall score
print(recall_score(target_test,prediction))
# Print the ROC/AUC score
print(roc_auc_score(target_test,prediction))

# Initialize the model
model_depth_7_b = 
# Fit it to the training component
model_depth_7_b.fit(____,____)
# Make prediction using test component
prediction_b = 
# Print the recall score for the balanced model
print(____)
# Print the ROC/AUC score for the balanced model
print(____)