ray-project / tune-sklearn

A drop-in replacement for Scikit-Learn’s GridSearchCV / RandomizedSearchCV -- but with cutting edge hyperparameter tuning techniques.
https://docs.ray.io/en/master/tune/api_docs/sklearn.html
Apache License 2.0
465 stars 52 forks source link

[Issue] TypeError: init() got an unexpected keyword argument 'include_dashboard' #155

Closed vectosaurus closed 3 years ago

vectosaurus commented 3 years ago

Running the hyperopt example for TuneSearchCV from the readme page yields the following error

TypeError: init() got an unexpected keyword argument 'include_dashboard'

This is the code I am running. I face the same issue with the 'bayesian' optimization too. How to fix this?


import scipy
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from sklearn.linear_model import SGDClassifier
X, y = make_classification(n_samples=11000, n_features=1000, n_informative=50, n_redundant=0, n_classes=10, class_sep=2.5)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=1000)

param_dists = {
    'alpha': (1e-4, 1e-1),
    'epsilon': (1e-2, 1e-1)
}

hyperopt_tune_search = TuneSearchCV(SGDClassifier(),
    param_distributions=param_dists,
    n_trials=2,
    early_stopping=True, # uses Async HyperBand if set to True
    max_iters=10,
    search_optimization="hyperopt"
)

hyperopt_tune_search.fit(X_train, y_train)
Yard1 commented 3 years ago

Does this issue persist on the master branch version of tune-sklearn?

vectosaurus commented 3 years ago

Yes, I've installed the library using pip. I am not using any other branches

Yard1 commented 3 years ago

Could you try pip install -U git+https://github.com/ray-project/tune-sklearn.git? This will install the development version of tune-sklearn. If the issue still persists after that, try updating your Ray package.

vectosaurus commented 3 years ago

@Yard1

I tried the install you provided but got the following error

ImportError: cannot import name 'Domain' from 'ray.tune.sample' (/home/ubuntu/anaconda3/lib/python3.7/site-packages/ray/tune/sample.py)

The command you gave installs tune-sklearn-0.0.8 so I went ahead and upgraded to tune-sklearn-0.1.0. Doing that now gives me the following error

TypeError: __init__() got an unexpected keyword argument 'sk_n_jobs'

Yard1 commented 3 years ago

The version number is a mistake on our part, the code I gave you will install the latest version of the package, consistent with the master branch of this repository.

You should update your Ray install.

pip uninstall ray tune-sklearn
pip install -U ray[tune]
pip install -U git+https://github.com/ray-project/tune-sklearn.git

This should work. Let me know how it goes.

vectosaurus commented 3 years ago

I tried the steps above, I am getting the same error-

TypeError: __init__() got an unexpected keyword argument 'sk_n_jobs'

I am using the example from here

Yard1 commented 3 years ago

Can you try creating a new conda/virtualenv environment and running the commands I posted again? There seems to be an issue with packages you have installed.

vectosaurus commented 3 years ago

@Yard1

This works with venv now. Thanks a lot for the inputs.

Lastly, could help me with a couple of things?

Thanks!

Yard1 commented 3 years ago

You can use tune's search spaces for all algorithms - https://docs.ray.io/en/master/tune/tutorials/overview.html#how-do-i-choose-hyperparameter-ranges. Just pass the config dict as param_distributions argument.

You can pass the fit arguments through the fit method of TuneSearchCV, eg.

hyperopt_tune_search.fit(X, y, my_fit_param="a")
vectosaurus commented 3 years ago

Thanks a lot @Yard1