ComparisonReport#
- class skore.ComparisonReport(reports, *, n_jobs=None)[source]#
Report for comparison of instances of
skore.EstimatorReport
.Caution: reports passed to
ComparisonReport
are not copied. If you pass a report toComparisonReport
, and then modify the report outside later, it will affect the report stored inside theComparisonReport
as well, which can lead to inconsistent results. For this reason, modifying reports after creation is strongly discouraged.- Parameters:
- reportslist of
EstimatorReport
instances or dict Estimator reports to compare.
If
reports
is a list, the class name of each estimator is used.If
reports
is a dict, it is expected to have estimator names as keys andEstimatorReport
instances as values. If the keys are not strings, they will be converted to strings.
- n_jobsint, default=None
Number of jobs to run in parallel. Training the estimators and computing the scores are parallelized. When accessing some methods of the
ComparisonReport
, then_jobs
parameter is used to parallelize the computation.None
means 1 unless in ajoblib.parallel_backend
context.-1
means using all processors.
- reportslist of
- Attributes:
- estimator_reports_list of
~skore.EstimatorReport
The compared estimator reports.
- report_names_list of str
The names of the compared estimator reports.
- estimator_reports_list of
See also
skore.EstimatorReport
Report for a fitted estimator.
skore.CrossValidationReport
Report for the cross-validation of an estimator.
Examples
>>> from sklearn.datasets import make_classification >>> from sklearn.model_selection import train_test_split >>> from sklearn.linear_model import LogisticRegression >>> from skore import ComparisonReport, EstimatorReport >>> X, y = make_classification(random_state=42) >>> X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42) >>> estimator_1 = LogisticRegression() >>> estimator_report_1 = EstimatorReport( ... estimator_1, ... X_train=X_train, ... y_train=y_train, ... X_test=X_test, ... y_test=y_test ... ) >>> estimator_2 = LogisticRegression(C=2) # Different regularization >>> estimator_report_2 = EstimatorReport( ... estimator_2, ... X_train=X_train, ... y_train=y_train, ... X_test=X_test, ... y_test=y_test ... ) >>> report = ComparisonReport([estimator_report_1, estimator_report_2]) ... >>> report = ComparisonReport( ... {"model1": estimator_report_1, "model2": estimator_report_2} ... ) ...
- cache_predictions(response_methods='auto', n_jobs=None)[source]#
Cache the predictions for sub-estimators reports.
- Parameters:
- response_methods{“auto”, “predict”, “predict_proba”, “decision_function”}, default=”auto
The methods to use to compute the predictions.
- n_jobsint, default=None
The number of jobs to run in parallel. If
None
, we use then_jobs
parameter when initializing the report.
Examples
>>> from sklearn.datasets import make_classification >>> from sklearn.linear_model import LogisticRegression >>> from sklearn.model_selection import train_test_split >>> from skore import ComparisonReport >>> X, y = make_classification(random_state=42) >>> X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42) >>> estimator_1 = LogisticRegression() >>> estimator_report_1 = EstimatorReport( ... estimator_1, ... X_train=X_train, ... y_train=y_train, ... X_test=X_test, ... y_test=y_test ... ) >>> estimator_2 = LogisticRegression(C=2) # Different regularization >>> estimator_report_2 = EstimatorReport( ... estimator_2, ... X_train=X_train, ... y_train=y_train, ... X_test=X_test, ... y_test=y_test ... ) >>> report = ComparisonReport([estimator_report_1, estimator_report_2]) >>> report.cache_predictions() >>> report._cache {...}
- clear_cache()[source]#
Clear the cache.
Examples
>>> from sklearn.datasets import make_classification >>> from sklearn.linear_model import LogisticRegression >>> from sklearn.model_selection import train_test_split >>> from skore import ComparisonReport >>> X, y = make_classification(random_state=42) >>> X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42) >>> estimator_1 = LogisticRegression() >>> estimator_report_1 = EstimatorReport( ... estimator_1, ... X_train=X_train, ... y_train=y_train, ... X_test=X_test, ... y_test=y_test ... ) >>> estimator_2 = LogisticRegression(C=2) # Different regularization >>> estimator_report_2 = EstimatorReport( ... estimator_2, ... X_train=X_train, ... y_train=y_train, ... X_test=X_test, ... y_test=y_test ... ) >>> report = ComparisonReport([estimator_report_1, estimator_report_2]) >>> report.cache_predictions() >>> report.clear_cache() >>> report._cache {}