ComparisonReport.create_estimator_report#
- ComparisonReport.create_estimator_report(*, report_key, X_test=None, y_test=None, test_data=None, concatenate_train_and_test=False)[source]
Create an estimator report from one of the reports in the comparison.
This method creates a new
EstimatorReportwith 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 theComparisonReport. List the available keys withreports_.keys().- X_test{array-like, sparse matrix} of shape (n_samples, n_features) or None
Testing data when the chosen report uses tabular scikit-learn
X/y. Must be provided together withy_testunless onlytest_datais used for a skrub-backed report.- y_testarray-like of shape (n_samples,) or (n_samples, n_outputs) or None
Testing target for tabular scikit-learn data.
- test_datadict or None
When the chosen report is skrub-backed, bindings for variables contained in the DataOp (e.g.
{"X": X_df, ...}) for the held-out evaluation set. Required in that case;X_testandy_testmust then be omitted.- concatenate_train_and_testbool, default=False
When the chosen entry is an
EstimatorReportbacked by tabular scikit-learn data, controls whether to concatenate that report’s train and test splits into a single training set before fitting on the held-outX_test/y_testyou provide. IfFalse(default), the new report is fit on the report’s originalX_train.This option must be
Falseifreport_keyrefers to aCrossValidationReportorthe estimator is a skrub
SkrubLearnerorthe estimator was built from a skrub
DataOp.
- Returns:
- report
EstimatorReport The estimator report.
- 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()