Skip to content

sklearn_tuner change Bool to Int #108

@Q-strong

Description

@Q-strong

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions