ComparisonReport.create_estimator_report#

ComparisonReport.create_estimator_report(*, report_key, X_test=None, y_test=None)[source]

Create an estimator report from one of the reports in the comparison.

This method creates a new EstimatorReport with the same estimator and the same data as the chosen report. It is useful to evaluate and deploy a model that was deemed optimal during the comparison. Provide a held out test set to properly evaluate the performance of the model.

Parameters:
report_keystr

The key associated with the estimator to create a report for, as stored in the reports_ attribute of the ComparisonReport. List the available keys with reports_.keys().

X_test{array-like, sparse matrix} of shape (n_samples, n_features) or None

Testing data. It should have the same structure as the training data.

y_testarray-like of shape (n_samples,) or (n_samples, n_outputs) or None

Testing target.

Returns:
reportEstimatorReport

The estimator report.

Examples

>>> from sklearn.datasets import make_classification
>>> from sklearn.ensemble import RandomForestClassifier
>>> from sklearn.linear_model import LogisticRegression
>>> from skore import train_test_split
>>> from skore import ComparisonReport, CrossValidationReport
>>> X, y = make_classification(random_state=42)
>>> X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
>>> linear_report = CrossValidationReport(
...     LogisticRegression(random_state=42), X_train, y_train
... )
>>> forest_report = CrossValidationReport(
...     RandomForestClassifier(random_state=42), X_train, y_train
... )
>>> comparison_report = ComparisonReport([linear_report, forest_report])
>>> summary = comparison_report.metrics.summarize().frame()
>>> # Notice that e.g. the RandomForestClassifier performs best
>>> final_report = comparison_report.create_estimator_report(
...     report_key="RandomForestClassifier", X_test=X_test, y_test=y_test
... )
>>> final_report.metrics.summarize().frame()