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

TuneSearchCV not Working [tune] #195

Closed abheesht17 closed 3 years ago

abheesht17 commented 3 years ago

What is the problem?

Consider this piece of code:

from ray.tune.sklearn import TuneSearchCV
from sklearn.linear_model import SGDClassifier
from sklearn import datasets
from sklearn.model_selection import train_test_split
import numpy as np

digits = datasets.load_digits()
x = digits.data
y = digits.target
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=.2)

clf = SGDClassifier()
parameter_grid = {"alpha": (1e-4, 1), "epsilon": (0.01, 0.1)}

tune_search = TuneSearchCV(
    clf,
    parameter_grid,
    search_optimization="bayesian",
    n_trials=3,
    early_stopping=True,
    max_iters=10,
)
tune_search.fit(x_train, y_train)
print(tune_search.best_params_)

This has been obtained from the docs. I am running the code on Colab. I have reproduced the error on the following link: https://colab.research.google.com/drive/1z2vpBE7HTS6Iq2G_h9MQWIL_Aw8pKzaT?usp=sharing

richardliaw commented 3 years ago

This just requires a better error message on our side. Please run pip install tune_sklearn.

abheesht17 commented 3 years ago

Thank you for the swift reply! It works now.