Exercise

Exporting the tree

In Decision Tree classification tasks, overfitting is usually the result of deeply grown trees. As the comparison of accuracy scores on the train and test sets shows, you have overfitting in your results. This can also be learned from the tree visualization.

In this exercise, you will export the decision tree into a text document, which can then be used for visualization.

Instructions

100 XP
  • Import the the export_graphviz() function from the the sklearn.tree submodule.
  • Fit the model to the training data.
  • Export the visualization to the file tree.dot.