Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sklearn_tuner change Bool to Int #108

Open
Q-strong opened this issue Mar 8, 2025 · 0 comments
Open

sklearn_tuner change Bool to Int #108

Q-strong opened this issue Mar 8, 2025 · 0 comments

Comments

@Q-strong
Copy link

Q-strong commented Mar 8, 2025

I got the error "The 'bootstrap' parameter of cross_val_predict must be an instance of 'bool' or an instance of 'numpy.bool_'. Got 0 instead." when running

from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import r2_score, mean_squared_error
from hebo.sklearn_tuner import sklearn_tuner
from sklearn.datasets import fetch_california_housing

data = fetch_california_housing()
X, y = data.data, data.target

space_cfg = [
        {'name' : 'max_depth',        'type' : 'int', 'lb' : 1, 'ub' : 20},
        {'name' : 'min_samples_leaf', 'type' : 'num', 'lb' : 1e-4, 'ub' : 0.5},
        {'name' : 'max_features',     'type' : 'cat', 'categories' : ['auto', 'sqrt', 'log2']},
        {'name' : 'bootstrap',        'type' : 'bool'},
        {'name' : 'min_impurity_decrease', 'type' : 'pow', 'lb' : 1e-4, 'ub' : 1.0},
        ]

result = sklearn_tuner(RandomForestRegressor, space_cfg, X, y, metric = r2_score, max_iter = 16)

The sklearn version is 1.6.1. I believe it may be because in line 35 of bool_param.py, the bool variable is treated as numeric, and then in line 79 of sklearn_tuner.py it changes the bool to int.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant