Aravinth
Aravinth

Reputation: 91

name 'tqdm_notebook' is not defined

I am trying to use the tqdm_notebook function but I am getting an error even after checking the installation of tqdm and ipywidgets.

from tqdm import tqdm_notebook as tqdm
for param in tqdm_notebook(parameters_list):
# we need try-except because on some combinations model fails to converge
    try:
        model=sm.tsa.statespace.SARIMAX(data, order=(param[0], d, param[1]),
        seasonal_order=(param[2], D, param[3], s)).fit(disp=-1)
    except:
        continue
aic = model.aic
# saving best model, AIC and parameters
if aic < best_aic:
    best_model = model
best_aic = aic
best_param = param
results.append([param, model.aic])

The errors shown is,

 NameError Traceback (most recent call last) <ipython-input-33-277a561b8f50> in <module>
      1 from tqdm import tqdm_notebook as tqdm
----> 2 for param in tqdm_notebook(parameters_list):
      3 # we need try-except because on some combinations model fails to converge
      4     try:
      5         model=sm.tsa.statespace.SARIMAX(data, order=(param[0], d, param[1]),

NameError: name 'tqdm_notebook' is not defined.

I have tried with pip install tqdm, pip install ipywidgets and jupyter nbextension enable --py widgetsnbextension. Everything looks fine but I am getting this error, how to rectify this.

Upvotes: 1

Views: 3980

Answers (3)

ac24
ac24

Reputation: 5565

Your code probably has an error when defining model, hence the name error that follows. However, because this code is in a bare except: block, this error is not getting raised, model is not getting defined, etc.

Instead of this:

    try:
        model=sm.tsa.statespace.SARIMAX(data, order=(param[0], d, param[1]),
        seasonal_order=(param[2], D, param[3], s)).fit(disp=-1)
    except:
        continue

use this code:

   model=sm.tsa.statespace.SARIMAX(data, order=(param[0], d, param[1]),
   seasonal_order=(param[2], D, param[3], s)).fit(disp=-1)

and then see what different error results.

Upvotes: 0

Why dont you try

from tqdm import *

Upvotes: 0

HKG
HKG

Reputation: 328

The correct import is

from tqdm.notebook import tqdm

See Advanced Usage section at their github repository

Also you've assigned tqdm_notebook to be tqdm.

Upvotes: 1

Related Questions