Failed to Importing Adida from statsforecast.models in Python

Viewed 35

I was trying to replicate this code for stat forecasting in python, I came across the issue of not being able to load this model 'adida' form statsforecast library,

Here is the link for reference : https://towardsdatascience.com/time-series-forecasting-with-statistical-models-f08dcd1d24d1

import random
from itertools import product
from IPython.display import display, Markdown
from multiprocessing import cpu_count

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from nixtlats.data.datasets.m4 import M4, M4Info

from statsforecast import StatsForecast
from statsforecast.models import (
    adida, 
    croston_classic, 
    croston_sba, 
    croston_optimized,
    historic_average,
    imapa,
    naive,
    random_walk_with_drift, 
    seasonal_exponential_smoothing,
    seasonal_naive, 
    seasonal_window_average,
    ses, 
    tsb,
    window_average
)

Attached is the error message, Can you please have a look at this and let me know why is there an issue in importing this?

Given below is the error image:

enter image description here

2 Answers

I did some research and figured out the issue is probably with the version, try installing this specific version of statsforecast

pip install statsforecasts==0.6.0

Trying loading these models after that, hopefully this should work.

As of v1.0.0 of StatsForecast, the API changed to be more like sklearn, using classes instead of functions. You can find an example of the new syntax here: https://nixtla.github.io/statsforecast/examples/IntermittentData.html.

The new code would be

from statsforecast import StatsForecast
from statsforecast.models import ADIDA, IMAPA

model = StatsForecast(df=Y_train_df, # your data
                      models=[ADIDA(), IMAPA()], 
                      freq=freq, # frequency of your data
                      n_jobs=-1)

If you want to use the old syntax, setting the version as suggested should work.

Related