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

Use len(classes_) instead of len(set(y_true)) #5275

Merged
merged 6 commits into from Jan 17, 2022
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions mlflow/sklearn/utils.py
Expand Up @@ -291,10 +291,18 @@ def _get_classifier_artifacts(fitted_estimator, prefix, X, y_true, sample_weight
def plot_confusion_matrix(*args, **kwargs):
import matplotlib

num_classes = len(set(y_true))
if hasattr(fitted_estimator, "classes_"):
classes = fitted_estimator.classes_
elif hasattr(fitted_estimator, "estimator") and hasattr(
fitted_estimator.estimator, "classes_"
harupy marked this conversation as resolved.
Show resolved Hide resolved
):
classes = fitted_estimator.estimator.classes_
else:
classes = set(y_true)

with matplotlib.rc_context(
{
"font.size": min(10.0, 50.0 / num_classes),
"font.size": min(10.0, 50.0 / len(classes)),
"axes.labelsize": 10.0,
}
):
Expand Down