Is it possible to turn off colorbar for classification_report?

14 views
Skip to first unread message

Chiff Chew

unread,
Feb 15, 2020, 10:46:44 AM2/15/20
to Yellowbrick
Hello, I was trying to turn off the color bar in the classification report as I'm showing a few of them side by side.

I tried setting colorbar=False in both the classification report instantiation and in the finalize, but it didn't work. I see that it's possible in PCA, and was wondering whether it's possible to do the same for classification report?

Thank you for all the hard work you guys put into writing this library!

Yellowbrick

unread,
Feb 15, 2020, 6:47:36 PM2/15/20
to Yellowbrick
Removing the colorbar is a bit trickier with ClassificationReport, but it is possible. The main problem with doing this to put several ClassificationReports side-by-side is that the color range may not represent the same values across all the plots -- (e.g. the values of one classifier range between 0.4 and 0.6 and another classifier between 0.3 and 0.9) ...

That said, you could try something like the below, which manually removes the second set of axes created on the figure (which are what contain the colorbar). You may need to remove the ticks. 

from yellowbrick.datasets import load_occupancy

from yellowbrick.classifier import ClassificationReport


from sklearn.linear_model import LogisticRegression



# load the data

X, y = load_occupancy()


# instantiate the visualizer object and fit-score it

viz = ClassificationReport(LogisticRegression(), classes=["occupied", "vacant"])

viz.fit(X,y)

viz.score(X,y)


# extract the figure from the visualizer object

fig = viz.ax.figure


# delete the second set of axes from the figure

fig.delaxes(fig.axes[1])


# show the remaining figure

fig.show()

Reply all
Reply to author
Forward
0 new messages