Search code examples
pythonoptimizationhyperopt

AttributeError: module 'hyperopt' has no attribute 'uniform'


I am trying to define a parameter space in hyperopt. However, when I run:

import hyperopt as hp
SPACE = {'d1': hp.uniform('d1',-1000000,-0.5),
'd2': hp.uniform('d2',0,1),
'd3': hp.uniform('d3',0,1)} 

I receive the error in the title. The only thing I found online was that I should try downgrading to networkx 1.11, so in the command prompt I ran:

pip install networkx==1.11

and it apparently worked, but still no luck with the attribute uniform.


Solution

  • The correct way to import the hp part of the hyperopt module is

    from hyperopt import hp
    

    You have used

    import hyperopt as hp