evaluate#
- skore.evaluate(estimator, X, y, *, splitter=0.2, pos_label=None, n_jobs=None)[source]#
Evaluate one or more estimators on the given data.
Passing several estimators provides a report to compare them, while the
splitterparameter controls whether a train-test split or cross-validation is used.- Parameters:
- estimatorestimator object or list of estimator objects
A scikit-learn compatible estimator, or a list of such estimators to compare.
- Xarray-like of shape (n_samples, n_features) or list of array-like
Feature matrix. When
estimatoris a list,Xcan also be a list of feature matrices (one per estimator) to e.g. compare models with different preprocessing pipelines.- yarray-like of shape (n_samples,)
Target vector.
- splitterfloat, int, str, or cross-validation object, default=0.2
Determines how the data is split:
float: perform a single train-test split where the data is shuffled before splitting with a fixed seed (random_state=0) for reproducibility. Pass aTrainTestSplitinstance for more control over the splitting parameters."prefit": the estimator is assumed to be already fitted;Xandyare used as the test set.int: number of folds for cross-validation (passed toCrossValidationReport).cross-validation splitter (e.g.
KFold,StratifiedKFold): passed directly toCrossValidationReport.
- pos_labelint, float, bool or str, default=None
The positive class label for binary classification metrics. Forwarded to the underlying report.
- n_jobsint or None, default=None
Number of jobs for parallel execution. Forwarded to
CrossValidationReportorComparisonReport.
- Returns:
- report
EstimatorReport,CrossValidationReportorComparisonReport The report corresponding to the evaluation strategy.
- report
- Raises:
- ValueError
If
splitteris a string other than"prefit".
Examples
>>> from sklearn.datasets import make_classification >>> from sklearn.linear_model import LogisticRegression >>> from skore import evaluate >>> X, y = make_classification(random_state=42)
Default 80/20 train-test split:
>>> report = evaluate(LogisticRegression(), X, y)
Cross-validation with 5 folds:
>>> report = evaluate(LogisticRegression(), X, y, splitter=5)
Evaluate a pre-fitted estimator:
>>> from sklearn.model_selection import train_test_split >>> X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42) >>> fitted_model = LogisticRegression().fit(X_train, y_train) >>> report = evaluate(fitted_model, X_test, y_test, splitter="prefit")
Gallery examples#
Using skore with scikit-learn compatible estimators
EstimatorReport: Inspecting your models with the feature importance