8000 Raise warning when fit/score fail in learning curve · Issue #22057 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content
Raise warning when fit/score fail in learning curve #22057
Closed
@glemaitre

Description

@glemaitre

This is a follow-up of #9913. The following code is expected to fail with unshuffled cross-validation since SVC cannot be fit with a single class.

import numpy as np
from sklearn.svm import SVC
from sklearn.model_selection import learning_curve
from sklearn.datasets import make_classification

X,y = make_classification(n_classes=3,  n_informative=6,  shuffle=False)

svc = SVC()
svc.fit(X,y)

# Error occurs here
train_sizes, train_scores, test_scores = learning_curve(svc, X, y, cv=10)

Since we have error_score=np.nan, we do not raise an error but instead output nan. This is the expected behaviour.
However, we could improve a bit more the user experience by adding a warning as done in GridSearchCV for instance to indicate the failures on the CV folds.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0