Skip to content

BUG: check_cv check for cv is 'warn' instead of cv == 'warn' which is raising an exception with n_jobs=-1 #12154

Closed
@glemaitre

Description

@glemaitre

In _split.py, cv is 'warn' will not work as intended since cv will be copied if n_jobs=-1.

from sklearn.datasets import load_iris                                               
from sklearn.model_selection import GridSearchCV                                     
from sklearn.model_selection import cross_validate                                   
from sklearn.svm import SVC                                                          
                                                                                     
X, y = load_iris(return_X_y=True)                                                    
clf = SVC(gamma='auto')                                                              
grid = GridSearchCV(clf, param_grid={'C': [1, 10]}, iid=False)                       
score = cross_validate(grid, X, y,                                                   
                       n_jobs=-1,                                                    
                       cv=5, error_score='raise')  # to remove deprecation warning
ValueError: Expected cv as an integer, cross-validation object (from sklearn.model_selection) or an iterable. Got warn.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions