D N
03/28/2024, 5:27 PMJosé Morales
03/28/2024, 5:30 PMD N
03/28/2024, 5:34 PMTraceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/pandas/core/indexes/base.py", line 3805, in get_loc
return self._engine.get_loc(casted_key)
File "index.pyx", line 167, in pandas._libs.index.IndexEngine.get_loc
File "index.pyx", line 196, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 7081, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 7089, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'unique_id'
José Morales
03/28/2024, 5:35 PMD N
03/28/2024, 5:36 PMD N
03/28/2024, 5:36 PMD N
03/28/2024, 5:40 PMD N
03/28/2024, 5:40 PMcv_df = nf.cross_validation(df, n_windows = 3, step_size = 1)
José Morales
03/28/2024, 5:41 PMD N
03/28/2024, 5:41 PMD N
03/28/2024, 5:42 PM1009 X 2024-03-21 178.18
1010 X 2024-03-22 166.30
1011 X 2024-03-25 175.24
1012 X 2024-03-26 184.25
D N
03/28/2024, 5:42 PMJosé Morales
03/28/2024, 5:42 PMD N
03/28/2024, 5:42 PMD N
03/28/2024, 5:43 PMJosé Morales
03/28/2024, 5:43 PMD N
03/28/2024, 5:43 PMdf = pd.read_csv(temp_dataset_path)
df = df.reset_index(drop=True)
df['ds'] = <http://pd.to|pd.to>_datetime(df['ds'])
D N
03/28/2024, 5:43 PMD N
03/28/2024, 5:44 PMD N
03/28/2024, 5:44 PMD N
03/28/2024, 5:45 PMJosé Morales
03/28/2024, 5:45 PMD N
03/28/2024, 5:47 PMD N
03/28/2024, 5:47 PMD N
03/28/2024, 5:49 PMD N
03/28/2024, 5:49 PMunique_id,ds,y
X,2020-03-18,23.37
X,2020-03-19,30.13
X,2020-03-20,31.8
X,2020-03-23,27.37
X,2020-03-24,34.25
X,2020-03-25,37.13
X,2020-03-26,37.33
X,2020-03-27,32.94
X,2020-03-30,32.75
José Morales
03/28/2024, 5:50 PMfrom neuralforecast import NeuralForecast
from neuralforecast.models import NHITS
from neuralforecast.utils import AirPassengersDF
nf = NeuralForecast(models=[NHITS(h=12, input_size=24, max_steps=1)], freq='M')
nf.cross_validation(df=AirPassengersDF, n_windows=3, step_size=1)
That's a small example. If you can provide one like that where there's an error I can help furtherD N
03/28/2024, 5:50 PMD N
03/28/2024, 5:51 PMD N
03/28/2024, 5:51 PMJosé Morales
03/28/2024, 5:51 PMD N
03/28/2024, 5:52 PMnf = NeuralForecast(
models=[
AutoMLP(h=nf_horizon, config=None, loss=HuberMQLoss(), num_samples=1, backend='optuna', verbose=False),
AutoNBEATS(h=nf_horizon, config=None, loss=HuberMQLoss(), num_samples=1, backend='optuna', verbose=False),
],
freq = nf_freq,
local_scaler_type = "robust"
)
D N
03/28/2024, 5:52 PMD N
03/28/2024, 5:56 PMD N
03/28/2024, 5:56 PMCV DF: ds cutoff ... AutoNBEATS-hi-90 y
unique_id ...
X 2024-03-21 2024-03-20 ... 183.480927 178.18
X 2024-03-22 2024-03-20 ... 185.534363 166.30
D N
03/28/2024, 5:56 PMJosé Morales
03/28/2024, 5:57 PMD N
03/28/2024, 5:58 PMD N
03/28/2024, 5:59 PMJosé Morales
03/28/2024, 6:01 PMfrom neuralforecast import NeuralForecast
from neuralforecast.auto import AutoMLP, AutoNBEATS
from neuralforecast.utils import AirPassengersDF
def config(trial):
return {
'input_size': 24,
'max_steps': 1,
}
nf = NeuralForecast(
models=[
AutoNBEATS(h=12, config=config, backend='optuna', num_samples=1),
AutoMLP(h=12, config=config, backend='optuna', num_samples=1)
],
freq='M',
)
print(nf.cross_validation(df=AirPassengersDF, n_windows=3, step_size=1))
without any issues.
If you can't provide an example like that where there's an error or a full stacktrace (including neuralforecast code) I can't help any furtherD N
03/28/2024, 6:02 PMJosé Morales
03/28/2024, 6:04 PMos.environ['NIXTLA_ID_AS_COL'] = '1'
you'll get the id as a column instead of the index in the predict and cross_validation outputs, which might helpD N
03/28/2024, 6:04 PMD N
03/28/2024, 6:05 PMJosé Morales
03/28/2024, 6:05 PMJosé Morales
03/28/2024, 6:06 PMJosé Morales
03/28/2024, 6:07 PMD N
03/28/2024, 6:08 PMD N
03/28/2024, 6:08 PMD N
03/28/2024, 6:09 PMJosé Morales
03/28/2024, 6:09 PMdf=AirPassengersDF.set_index('unique_id')
I get the key error. So you should be able to fix it by doing df.reset_index()
. We'll fix it on our side as well but in the meantime that should work for youD N
03/28/2024, 6:09 PMD N
03/28/2024, 6:09 PMD N
03/28/2024, 6:10 PMdf = pd.read_csv(temp_dataset_path)
df = df.reset_index(drop=True)
D N
03/28/2024, 6:10 PMJosé Morales
03/28/2024, 6:10 PMdf = df.reset_index()
?D N
03/28/2024, 6:11 PMD N
03/28/2024, 6:23 PMD N
03/28/2024, 6:23 PMevaluation_df = evaluate(cv_df.loc[:, cv_df.columns != 'cutoff'], metrics=[mae, mse, mape])
evaluation_df['best_model'] = evaluation_df.drop(columns=['metric', 'unique_id']).idxmin(axis=1)
D N
03/28/2024, 6:23 PMJosé Morales
03/28/2024, 6:24 PMD N
03/28/2024, 6:24 PMD N
03/28/2024, 6:31 PMD N
03/28/2024, 6:31 PMD N
03/28/2024, 6:31 PMJosé Morales
03/28/2024, 6:33 PMD N
03/28/2024, 6:35 PMD N
03/28/2024, 6:35 PMScottfree Analytics LLC
03/28/2024, 7:43 PMJosé Morales
03/28/2024, 7:47 PM