Member-only story
Scikit-learn Visualization Guide: Making Models Speak
Use the Display API to replace complex Matplotlib code
Introduction
In the journey of machine learning, explaining models with visualization is as important as training them.
A good chart can show us what a model is doing in an easy-to-understand way. Here’s an example:
This graph makes it clear that for the same dataset, the model on the right is better at generalizing.
Most machine learning books prefer to use raw Matplotlib code for visualization, which leads to issues:
- You have to learn a lot about drawing with Matplotlib.
- Plotting code fills up your notebook, making it hard to read.
- Sometimes you need third-party libraries, which isn’t ideal in business settings.
Good news! Scikit-learn now offers Display
classes that let us use methods like from_estimator
and from_predictions
to make drawing graphs for different situations much easier.