From the course: Machine Learning with Scikit-Learn

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

How to visualize decision trees using Matplotlib

How to visualize decision trees using Matplotlib - scikit-learn Tutorial

From the course: Machine Learning with Scikit-Learn

Start my 1-month free trial

How to visualize decision trees using Matplotlib

- [Instructor] How do you understand how decision tree makes predictions? One of the strengths of decision trees, are they're relatively easy to interpret, as you can make a visualization based on your model. This is not only a powerful way to understand your model, but also to communicate how a model works as stakeholders. In this video, I'll show you how decision trees, can be plotted with Matplotlid . The first thing you have to do, is import libraries. Take note that you're also importing tree. This is what actually plots to the decision tree. The next step is a loaded dataset, in this case is the Iris dataset. From there, you can split your data into training and test sets. This is really important for decision trees, as they tend to be a high variance algorithm. What this means, is they tend to overfit on the training set. The next step is to create a decision tree model. Before you can make a visualization based…

Contents