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
{{ message }}
This repository was archived by the owner on Feb 28, 2024. It is now read-only.
I am working on a multilabel classification and for now I have primarily been relying on RandomizedSearchCV from scikit-learn to perform hyperparameter optimization. I now started experimenting with BayesSearchCV and ran into a potential bug when using multi-metric scoring, combined with the refit argument.
I created a full reproducible toy example below.
Imports, data generation, pipeline:
import numpy as np
from sklearn.datasets import make_multilabel_classification
from sklearn.naive_bayes import MultinomialNB
from sklearn.multioutput import MultiOutputClassifier
from sklearn.model_selection import RandomizedSearchCV
from skopt.searchcv import BayesSearchCV
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import MinMaxScaler
X, Y = make_multilabel_classification(
n_samples=10000,
n_features=20,
n_classes=10,
n_labels=3
)
pipe = Pipeline(
steps = [
('scaler', MinMaxScaler()),
('model', MultiOutputClassifier(MultinomialNB()))
]
)
(Note: adding return_train_score=True to BayesSearchCV() didn't make a difference.)
The error message is:
File "multioutput.py", line 46, in <module>
).fit(X, Y)
File ".venv\lib\site-packages\skopt\searchcv.py", line 466, in fit
super().fit(X=X, y=y, groups=groups, **fit_params)
File ".venv\lib\site-packages\sklearn\model_selection\_search.py", line 891, in fit
self._run_search(evaluate_candidates)
File ".venv\lib\site-packages\skopt\searchcv.py", line 514, in _run_search
evaluate_candidates, n_points=n_points_adjusted
File ".venv\lib\site-packages\skopt\searchcv.py", line 411, in _step
local_results = all_results["mean_test_score"][-len(params):]
KeyError: 'mean_test_score'
For comparison, I ran the same setup through RandomizedSearchCV from scikit-learn:
Uh oh!
There was an error while loading. Please reload this page.
I am working on a multilabel classification and for now I have primarily been relying on
RandomizedSearchCV
fromscikit-learn
to perform hyperparameter optimization. I now started experimenting withBayesSearchCV
and ran into a potential bug when using multi-metric scoring, combined with therefit
argument.I created a full reproducible toy example below.
Imports, data generation, pipeline:
Step 1: Single metric with
refit = True
: works!Step 2: Single metric with
refit = 'precision_macro'
: works!Step 3: Multiple metrics with
refit = 'precision_macro'
: fails!(Note: adding
return_train_score=True
toBayesSearchCV()
didn't make a difference.)The error message is:
For comparison, I ran the same setup through
RandomizedSearchCV
fromscikit-learn
:and it evaluated correctly.
My version of scikit-optimize: 0.9.0.
OS: Windows 10
The text was updated successfully, but these errors were encountered: