Skip to content

Commit 57a26ae

Browse files
authored
Store CV results if any (#91)
* Store CV results if any When using a `GridSearchCV` or equivalent as estimator, it is often useful to have access to CV results. This is of particular importance when having multiple scorers, as otherwise it is not possible to access the other scorers results. * Fix checks Checks were done badly and failed if the returned object was an empty container or 0.
1 parent 89b5b8e commit 57a26ae

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

skdatasets/utils/experiment.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,19 @@ def _benchmark_from_data(
213213
_append_info(experiment, "fitted_estimator", estimator)
214214

215215
best_params = getattr(estimator, "best_params_", None)
216-
if best_params:
216+
if best_params is not None:
217217
_append_info(experiment, "search_best_params", best_params)
218218

219+
best_index = getattr(estimator, "best_index_", None)
220+
if best_index is not None:
221+
_append_info(experiment, "search_best_index", best_index)
222+
223+
cv_results = getattr(estimator, "cv_results_", None)
224+
if cv_results is not None:
225+
_append_info(experiment, "search_cv_results", cv_results)
226+
219227
best_score = getattr(estimator, "best_score_", None)
220-
if best_params:
228+
if best_score is not None:
221229
_append_info(experiment, "search_best_score", best_score)
222230

223231
with _add_timing(experiment, "score_time"):

0 commit comments

Comments
 (0)