Closed
Description
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.