-1

I want to run a python notebook that is part of a project I downloaded from Github. When I run a .ipynb file I get an error:

import pickle
import warnings
from math import sqrt

import lightgbm as lgb
import matplotlib as mpl
import numpy as np
import pandas as pd  # Basic library for all of our dataset operations
import pmdarima as pm
import tensorflow as tf
import xgboost as xgb
from bayes_opt import BayesianOptimization
from fbprophet import Prophet
from gluonts.dataset.common import ListDataset
from gluonts.evaluation.backtest import make_evaluation_predictions
from gluonts.model.deepar import DeepAREstimator
from gluonts.mx.trainer import Trainer
from matplotlib import pyplot as plt
from sklearn import linear_model, svm
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import make_scorer, mean_squared_error
from sklearn.model_selection import GridSearchCV, cross_val_score
from sklearn.neighbors import KNeighborsRegressor
from sklearn.preprocessing import StandardScaler
from statsmodels.tsa.ar_model import AR
from statsmodels.tsa.arima_model import ARIMA, ARMA
from statsmodels.tsa.holtwinters import ExponentialSmoothing, SimpleExpSmoothing
from statsmodels.tsa.statespace.sarimax import SARIMAX
from tqdm import tqdm

from utils.metrics import evaluate

This is the error I get:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-7-b033063c2c35> in <module>
     29 from tqdm import tqdm
     30 
---> 31 from utils.metrics import evaluate

ModuleNotFoundError: No module named 'utils.metrics'

I tried to apply the solution suggested here but it doesn't work for me.

This is how the folder containing the code looks like, the code above is from 02-Forecasting_models.ipynb:

enter image description here

If anyone has any idea as to how I can solve this, I would be very grateful. Thank you.

Saïd Maanan
  • 511
  • 4
  • 14

1 Answers1

0

I suspect you start the jupyter notebook from a different location. The current directory is different from the one where the project is. At the file beginning, try to call

import os
os.chdir("directory of your project")
Patrik Valkovič
  • 706
  • 7
  • 26