Session Ready
Exercise

Check our results

Once we have an optimized model, we want to check how it is performing in more detail. We already saw the R\(^2\) score, but it can be helpful to see the predictions plotted vs actual values. We can use the .predict() method of our decision tree model to get predictions on the train and test sets.

Ideally, we want to see diagonal lines from the lower left to the upper right. However, due to the simplicity of decisions trees, our model is not going to do well on the test set. But it will do well on the train set.

Instructions
100 XP
  • Create a DecisionTreeRegressor model called decision_tree using 3 for the max_depth hyperparameter.
  • Make predictions on the train and test sets (train_features and test_features) with our decision tree model.
  • Scatter the train and test predictions vs the actual target values with plt.scatter(), and set the label argument equal to test for the test set.