Hyperopt: ModuleNotFoundError: No module named 'hpsklearn'

Created on 11 Dec 2018  ·  4Comments  ·  Source: hyperopt/hyperopt

Greetings from NL.

I both pip installed and Conda installed Hyperopt but running the example case I get this error.

I ran a snippet from a collegue (that does not call for hpsklearn and that ran fine.

Any idea?

Thanks!

Maarten


ModuleNotFoundError Traceback (most recent call last)
in ()
1 from hyperopt import hp
----> 2 from hpsklearn import HyperoptEstimator, SGDClassifier
3 from sklearn.datasets import fetch_mldata
4 from hyperopt import tpe
5 import numpy as np

ModuleNotFoundError: No module named 'hpsklearn'

Most helpful comment

After installing hyperopt-sklearn I had to restart Jupyter to get rid of ModuleNotFoundError error. It is usually not needed.

All 4 comments

hpsklearn is from the hyperopt-sklearn project, which is a separate package built on top of hyperopt. You'll need to install it to use it. You can do that with pip install git+https://github.com/hyperopt/hyperopt-sklearn If you don't need it, just comment out that line.

There also isn't a component called SGDClassifier in that package, it's just called sgd so your colleague must be using a different version or something. Either way this isn't an issue with either package, it's a problem with your particular script and/or missing dependencies.

Hi Brent,

Thanks, I believe I did this before, but somehow it runs now :-)

While I got you on the line:

  1. In which directory should hpsklearn be installed? Should it be anaconda//lib/python3.6/site-packages ? I previously ran the install from a couple of working directories and I have several copies now.
  2. I am a bit confused over the notation: classifier=svc('mySVC’) or [ pca('my_pca’) what does the “mySVC” or ‘my_pca’ stand for?

Keep up the good work! Especially the any_classifier is almost becoming a auto learner

Best wishes from NL,
Maarten Kool

On 11 Dec 2018, at 23:21, Brent Komer notifications@github.com wrote:

pip install git+https://github.com/hyperopt/hyperopt-sklearn

Good to hear that it's working!

  1. Whichever directory you normally install things to, that looks like a reasonable place for it. When you pip install it should hopefully be putting it in the right place (assuming your anaconda env is activated when you install). Note that if you clone it from github it doesn't matter where it is saved, because once you do pip install -e . in that directory it'll put a copy in the right place.

  2. The 'my_pca' is just an arbitrary unique name. Typically in docs when someone writes my_something it means the user can put whatever they want there. The name is mostly there to disambiguate parameters that have the same name but should be different. For example, say you have a pipeline that involves two different SVCs, you could name one of them 'svc1' and the other 'svc2' so that hyperopt-sklearn doesn't get confused about which parameter belongs to which classifier. For most use cases you don't need to worry about this at all, just put in any string.

After installing hyperopt-sklearn I had to restart Jupyter to get rid of ModuleNotFoundError error. It is usually not needed.

Was this page helpful?
0 / 5 - 0 ratings