Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConfusionMatrix visualizer error with sklearn models #1292

Open
AmericaBG opened this issue Dec 14, 2022 · 3 comments
Open

ConfusionMatrix visualizer error with sklearn models #1292

AmericaBG opened this issue Dec 14, 2022 · 3 comments

Comments

@AmericaBG
Copy link

Hello!
I try to do a simple example like:

from sklearn.datasets import load_digits
from sklearn.model_selection import train_test_split as tts
from sklearn.linear_model import LogisticRegression
from yellowbrick.classifier import ConfusionMatrix

# We'll use the handwritten digits data set from scikit-learn.
# Each feature of this dataset is an 8x8 pixel image of a handwritten number.
# Digits.data converts these 64 pixels into a single array of features
digits = load_digits()
X = digits.data
y = digits.target

X_train, X_test, y_train, y_test = tts(X, y, test_size =0.2, random_state=11)

model = LogisticRegression(multi_class="auto", solver="liblinear")

# The ConfusionMatrix visualizer taxes a model
cm = ConfusionMatrix(model, classes=[0,1,2,3,4,5,6,7,8,9])

# Fit fits the passed model. This is unnecessary if you pass the visualizer a pre-fitted model
cm.fit(X_train, y_train)

# To create the ConfusionMatrix, we need some test data. Score runs predict() on the data
# and then creates the confusion_matrix from scikit-learn.
cm.score(X_test, y_test)

# How did we do?
cm.show()

The following error raised: AttributeError: 'LogisticRegression' object has no attribute 'classes'

This type of confussion matrix visualization worked a few days ago, could it be due to incompatibility between library versions?

Thank you very much in advance!

@rebeccabilbro
Copy link
Member

Hello @AmericaBG and thank you for using Yellowbrick. In order to help you, we will need you to provide information about your system and the package versions you are using locally, specifically:

  • Your operating system: [e.g. macOS]
  • Your Python Version [e.g. 2.7, 3.6, miniconda]
  • Your Yellowbrick Version [e.g. 0.7]

If you could also provide your scikit-learn version, that would be very helpful.

@AmericaBG
Copy link
Author

AmericaBG commented Dec 15, 2022 via email

@ArSenic04
Copy link

Use ClassificationReport instead but I cannot find where to edit can you help me with that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants