Search code examples
pythonhyperopt

TypeError: "set_postfix() argument after ** must be a mapping, not str" using Hyperopt


I try to run this simple example:

from hyperopt import fmin, tpe, hp

best = fmin(
fn=lambda x: (x-1)**2,
space=hp.uniform('x', -2, 2),
algo=tpe.suggest,
max_evals=100)

print(best)

But this is what i get in the console:

...\WinPython\python-3.6.5.amd64\Lib\site-packages\tqdm\_tqdm.py", line 792, in __init__
self.set_postfix(refresh=False, **postfix)

TypeError: set_postfix() argument after ** must be a mapping, not str

Why?

Thank you in advance!


Solution

  • Not sure if this is helpful. I was facing the same error when i try to tune the randomforest classifier model. I changed my objective function arguments from **params to *args and it fixed the error :)