You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a software developer, I want to track the improvement of ML model over iterations using multiple scoring metrics. This is a default behavior of parameter searching algorithms in sklearn (e.g., GridSearchCV ). Though able to use same API, NatureInspiredSearchCV raises a KeyError.
This seems to be due to default cv_results key used for evaluation, that changes from 'mean_test_score' to f'mean_test_{self.refit}'. However, method refit is not passed to ParameterSearch.
Simplest Possible Self-Contained Example Showing the Bug
Exception has occurred: KeyErrorException has occurred: KeyError
'mean_test_score'
File "./Sklearn-Nature-Inspired-Search/sklearn_nature_inspired_algorithms/model_selection/_parameter_search.py", line 39, in _evaluate
mean_test_score = cv_results['mean_test_score']
File "./Sklearn-Nature-Inspired-Search/sklearn_nature_inspired_algorithms/model_selection/_stagnation_stopping_task.py", line 40, in eval
x_f = super().eval(A)
File "./Sklearn-Nature-Inspired-Search/sklearn_nature_inspired_algorithms/model_selection/nature_inspired_search_cv.py", line 47, in _run_search
self.__algorithm.run(task=task)
File "./Sklearn-Nature-Inspired-Search/sklearn_nature_inspired_algorithms/model_selection/nature_inspired_search_cv.py", line 19, in fit
return super().fit(X, y, groups=groups, **fit_params)
File "./RnD/Similarity/bug_nia.py", line 15, in
scoring=scoring, refit=False).fit(X, y)
KeyError: 'mean_test_score'
The text was updated successfully, but these errors were encountered:
Complete Description of the Issue
As a software developer, I want to track the improvement of ML model over iterations using multiple scoring metrics. This is a default behavior of parameter searching algorithms in sklearn (e.g., GridSearchCV ). Though able to use same API, NatureInspiredSearchCV raises a KeyError.
This seems to be due to default
cv_results
key used for evaluation, that changes from'mean_test_score'
tof'mean_test_{self.refit}'
. However, methodrefit
is not passed toParameterSearch
.Simplest Possible Self-Contained Example Showing the Bug
Full Backtrace of Exception
Exception has occurred: KeyError
Exception has occurred: KeyError 'mean_test_score' File "./Sklearn-Nature-Inspired-Search/sklearn_nature_inspired_algorithms/model_selection/_parameter_search.py", line 39, in _evaluate mean_test_score = cv_results['mean_test_score'] File "./Sklearn-Nature-Inspired-Search/sklearn_nature_inspired_algorithms/model_selection/_stagnation_stopping_task.py", line 40, in eval x_f = super().eval(A) File "./Sklearn-Nature-Inspired-Search/sklearn_nature_inspired_algorithms/model_selection/nature_inspired_search_cv.py", line 47, in _run_search self.__algorithm.run(task=task) File "./Sklearn-Nature-Inspired-Search/sklearn_nature_inspired_algorithms/model_selection/nature_inspired_search_cv.py", line 19, in fit return super().fit(X, y, groups=groups, **fit_params) File "./RnD/Similarity/bug_nia.py", line 15, in scoring=scoring, refit=False).fit(X, y) KeyError: 'mean_test_score'
The text was updated successfully, but these errors were encountered: