skore
.cross_validate#
- skore.cross_validate(*args, project: Project | None = None, **kwargs) dict #
Evaluate estimator by cross-validation and output UI-friendly object.
This function wraps scikit-learn’s
cross_validate()
function, to provide more context and facilitate the analysis. As such, the arguments are the same as scikit-learn’scross_validate
function.The dict returned by this function is a strict super-set of the one returned by scikit-learn’s
cross_validate()
.For a user guide and in-depth example, see Enhancing cross-validation.
- Parameters:
- *args
Positional arguments accepted by scikit-learn’s
cross_validate()
, such asestimator
andX
.- projectProject, optional
A project to save cross-validation data into. If None, no save is performed.
- **kwargs
Additional keyword arguments accepted by scikit-learn’s
cross_validate()
.
- Returns:
- cv_resultsdict
A dict of the form returned by scikit-learn’s
cross_validate()
function.
Examples
>>> def prepare_cv(): ... from sklearn import datasets, linear_model ... diabetes = datasets.load_diabetes() ... X = diabetes.data[:150] ... y = diabetes.target[:150] ... lasso = linear_model.Lasso() ... return lasso, X, y
>>> project = skore.load("project.skore") >>> lasso, X, y = prepare_cv() >>> cross_validate(lasso, X, y, cv=3, project=project) {'fit_time': array(...), 'score_time': array(...), 'test_score': array(...)}