简体   繁体   English

Python 调整混淆矩阵的尺度强度 plot

[英]Python adjust scale intensity at confusion matrix plot

I have a number of confusion matrix plots with numbers not summing up to the same sum (the numbers are out of 100 for a benchmark) Please see attached example image below: confusion matrix I do not want the 22 and the 32 have the same color intensity, but be at the same scale from 0 to 100 intensity levels.我有许多混淆矩阵图,其中数字的总和不相同(基准数字超过 100)请参阅下面的示例图片:混淆矩阵我不希望 22 和 32 具有相同的颜色强度,但在从 0 到 100 强度级别的相同范围内。 How can I adjust the scale in python given the following used code:给定以下使用代码,如何调整 python 中的比例:

import matplotlib.pyplot as plt
from sklearn.datasets import make_classification
from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay

cm = confusion_matrix(y_true, y_pred, labels=["Up", "Down"])
disp = ConfusionMatrixDisplay(confusion_matrix=cm,display_labels=["Up", "Down"])
disp.plot(cmap="OrRd")
disp.ax_.get_images()[0].set_clim(0, 100)

And the full code:和完整的代码:

import matplotlib.pyplot as plt
from sklearn.datasets import make_classification
from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay

cm = confusion_matrix(y_true, y_pred, labels=["Up", "Down"])

disp = ConfusionMatrixDisplay(confusion_matrix=cm,display_labels=["Up", "Down"])
disp.plot(cmap="OrRd")

disp.ax_.get_images()[0].set_clim(0, 100)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM