In [4]:
%load_ext autoreload
%autoreload 2

%matplotlib inline

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload
In [5]:
plt.rcParams['figure.figsize'] = [14, 9]
In [6]:
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression

X, y = make_classification(n_samples=1000, n_informative=5, n_classes=10, random_state=0)
clf = LogisticRegression(solver='lbfgs', max_iter=1000, multi_class='multinomial')
clf.fit(X, y)
Out[6]:
LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,
                   intercept_scaling=1, l1_ratio=None, max_iter=1000,
                   multi_class='multinomial', n_jobs=None, penalty='l2',
                   random_state=None, solver='lbfgs', tol=0.0001, verbose=0,
                   warm_start=False)
In [8]:
from sklearn_plot_api import plot_confusion_matrix

First plot

In [9]:
viz = plot_confusion_matrix(clf, X, y)

Change cmap

In [10]:
viz.im_.set_cmap('plasma')
viz.figure_
Out[10]:
In [11]:
viz.plot(cmap='plasma')
Out[11]:
<sklearn_plot_api.confusion_matrix.ConfusionMatrixViz at 0x1a1db1b358>

Include values

In [12]:
viz.plot(include_values=True)
Out[12]:
<sklearn_plot_api.confusion_matrix.ConfusionMatrixViz at 0x1a1db1b358>