hyperopt / hyperopt-sklearn

Hyper-parameter optimization for sklearn
hyperopt.github.io/hyperopt-sklearn
Other
1.59k stars 272 forks source link

AssertionError: assert regressor is not None #64

Closed LishengSun closed 7 years ago

LishengSun commented 7 years ago

Hello,

I am using hpsklearn for the first time. When doing the following basic things:

>>> from hpsklearn import HyperoptEstimator
>>> estimator = HyperoptEstimator()

I got the AssertionError:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "hpsklearn/estimator.py", line 466, in __init__
    assert regressor is not None
AssertionError

Can you tell me why? By the way I am using sklearn 0.18 with anaconda python 2.7.

Thank you in advance!

bjkomer commented 7 years ago

That is definitely a bug, it looks like no default is being set if you don't specify a classifier or regressor. I'll work on getting a fix for that.

To get around that for now, you could pass in what sort of space you want to search. For example, if you want to search through all types of supported classifiers, you could do:

from hpsklearn import HyperoptEstimator, any_classifier
estimator = HyperoptEstimator(classifier=any_classifier('my_clf'))

Or if you just want to search a specific classifier, such as K-Nearest Neighbors:

from hpsklearn import HyperoptEstimator, knn
estimator = HyperoptEstimator(classifier=knn('my_knn'))

Now that I think about it, there isn't a nice list anywhere of all of the classifiers/regressors/preprocessing options, so that should get added as well.

LishengSun commented 7 years ago

Thank you very much! That solved my problem!