Labels are sometimes cut off in ConfusionMatrix
See original GitHub issueDescribe the bug
When a dictionary of encoding-to-string mappings is provided to the ConfusionMatrix
so that the class names will appear as labels, sometimes the class and axis labels get cut off.
To Reproduce
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split as tts
from yellowbrick.classifier import ConfusionMatrix
iris = load_iris()
iris_X = iris.data
iris_y = iris.target
iris_classes = iris.target_names
i_X_train, i_X_test, i_y_train, i_y_test = tts(
iris_X, iris_y, test_size=0.2
)
model = LogisticRegression()
iris_cm = ConfusionMatrix(
model, classes=iris_classes,
label_encoder={0: 'setosa', 1: 'versicolor', 2: 'virginica'}
)
iris_cm.fit(i_X_train, i_y_train)
iris_cm.score(i_X_test, i_y_test)
i = iris_cm.poof()
Desktop (please complete the following information):
- OS: macOS
- Python Version 3.6
- Yellowbrick Version 0.8
Additional context Note that the behavior appears to be somewhat different when the code is executed inside a Jupyter notebook. Discovered in the process of working on #611
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Error in Confusion Matrix : the data and reference factors must ...
I had the same issue. I guess it happened because data argument was not casted as factor as I expected. Try: confusionMatrix(pred,as.factor(testing$Final)).
Read more >Understanding Confusion Matrix | by Sarang Narkhede
Confusion Matrix is a performance measurement for machine learning ... very best of Towards Data Science: from hands-on tutorials and cutting-edge research ...
Read more >Determining a Cut-Off or Threshold When Working ... - Medium
dfx['DECILE'] = pd.qcut(dfx['P_FAIL'], 10, labels=np.arange(100, 0, -10)) ... Again, a cut-off (threshold) is required to build a confusion matrix.
Read more >Confusion Matrix for Machine Learning - Analytics Vidhya
There are plenty of ways to gauge the performance of your classification model but none have stood the test of time like the...
Read more >alternative cut-off confusion matrix - JMP User Community
I have used the alternative cut-off probability confusion matrix add-in many times. Suddenly it is producing nonsensical results on some ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am reopening this issue because during my implementation of plot directive for the ConfusionMatrix Docs #747 I came across it again. It doesn’t appear to be fixed with recent mpl updates.
I think I might have found a partial solution (also at #768). I found that adding the keyword
bbox_inches='tight'
topoof
fixed the cutoff.Before
bbox_inches='tight'
After
bbox_inches='tight'