Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

HR Analytics: Predicting Employee Churn in Python

Cursus bekijken

Oefeninstructies

  • 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.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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(____)
Code bewerken en uitvoeren