Phi Nguyen
09/08/2022, 4:42 PMPhi Nguyen
09/08/2022, 4:43 PMfrom time import time
import ray
import pandas as pd
#from neuralforecast.data.datasets.m5 import M5, M5Evaluation
from statsforecast import StatsForecast
from statsforecast.models import ETS
ray.init(address="auto")
Y_df = pd.read_parquet('<s3://m5-benchmarks/data/train/target.parquet>')
Y_df = Y_df.rename(columns={
'item_id': 'unique_id',
'timestamp': 'ds',
'demand': 'y'
})
Y_df['ds'] = pd.to_datetime(Y_df['ds'])
Y_df = Y_df[Y_df.unique_id == "FOODS_1_001_CA_1"]
constant = 10
Y_df['y'] += constant
fcst = StatsForecast(
df=Y_df,
models=[ETS(season_length=7, model='ZNA')],
freq='D'
)
Y_hat = fcst.forecast(28)
Max (Nixtla)
09/08/2022, 4:53 PMY_df = Y_df[Y_df.unique_id == "FOODS_1_001_CA_1"]
# The problem was that the type was a category.
# Add this line
Y_df['unique_id'] = Y_df['unique_id'].astype(str)
Max (Nixtla)
09/08/2022, 4:54 PMfrom time import time
import ray
import pandas as pd
#from neuralforecast.data.datasets.m5 import M5, M5Evaluation
from statsforecast import StatsForecast
from statsforecast.models import ETS
ray.init(address="auto")
Y_df = pd.read_parquet('<s3://m5-benchmarks/data/train/target.parquet>')
Y_df = Y_df.rename(columns={
'item_id': 'unique_id',
'timestamp': 'ds',
'demand': 'y'
})
Y_df['ds'] = pd.to_datetime(Y_df['ds'])
Y_df = Y_df[Y_df.unique_id == "FOODS_1_001_CA_1"]
# Add this line
Y_df['unique_id'] = Y_df['unique_id'].astype(str)
constant = 10
Y_df['y'] += constant
fcst = StatsForecast(
df=Y_df,
models=[ETS(season_length=7, model='ZNA')],
freq='D'
)
Y_hat = fcst.forecast(28)
Phi Nguyen
09/08/2022, 5:35 PMSlackbot
09/12/2022, 4:09 PMSlackbot
09/13/2022, 9:47 PMSlackbot
09/14/2022, 4:50 PMSlackbot
09/19/2022, 8:32 AMSlackbot
09/26/2022, 11:55 PMGinger Holt
09/28/2022, 10:29 PMSlackbot
09/28/2022, 10:42 PMGinger Holt
09/29/2022, 5:17 PMSlackbot
09/29/2022, 5:19 PMSlackbot
10/06/2022, 3:43 PMJ T
10/06/2022, 9:14 PMJ T
10/06/2022, 9:15 PMRan under AZ databrick.
here is the code:
#Select SARIMA with seasonality 12
autoARIMA = AutoARIMA(season_length=12)
# Select ETS with seasonality 12 and multiplicative trend
model = StatsForecast(df=products2.set_index('unique_id'),
models=[autoARIMA],
freq='m', n_jobs=-1)
Y_hat_df = model.forecast(horizon).reset_index()
J T
10/06/2022, 9:16 PMSlackbot
10/06/2022, 9:20 PMValeriy
10/09/2022, 11:34 AMMax (Nixtla)
10/10/2022, 2:56 PMSlackbot
10/11/2022, 9:28 AMValeriy
10/11/2022, 9:29 AMValeriy
10/11/2022, 9:30 AMJ T
10/14/2022, 6:10 PMSlackbot
10/14/2022, 6:55 PMMax (Nixtla)
10/14/2022, 6:58 PMconda env create --name statsforecastenv --file=environment.yml
And then
source activate statsforecastenv
Slackbot
10/17/2022, 12:58 PMSlackbot
10/23/2022, 2:31 AM