Session Ready
Exercise

Regularization

Regularization is the process of adding information to a model in order to prevent overfitting. This is important in order to boost the evaluation metrics you saw earlier in the chapter. In this exercise, you will vary around the max depth parameter of a decision tree in order to see how the classification results are affected.

X_train, y_train, X_test, y_test are available in your workspace. pandas as pd, numpy as np, and sklearn are also available in your workspace. Additionally, confusion_matrix(), precision_score(), and recall_score() from sklearn.metrics are available.

Instructions
100 XP
  • Create different decision trees by varying the maximum depth of each tree.
  • For each tree, fit and produce predictions on testing data.
  • Evaluate the confusion matrix, precision, and recall for each tree.