Chris Gervais
01/06/2023, 2:19 PMsktime
) with the neuralforecast
native cross-validation but we're running into a merge issue. The culprit seems to be in the core NeuralForecast
class here:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[56], line 1
----> 1 nf.cross_validation(df=df, static_df=static_df, val_size=val_size)
File ~/Desktop/rtobots/.venv/lib/python3.9/site-packages/neuralforecast/core.py:386, in NeuralForecast.cross_validation(self, df, static_df, n_windows, step_size, val_size, test_size, sort_df, verbose, **data_kwargs)
383 fcsts_df = pd.concat([fcsts_df, fcsts], axis=1)
385 # Add original input df's y to forecasts DataFrame
--> 386 fcsts_df = fcsts_df.merge(df, how="left", on=["unique_id", "ds"])
387 return fcsts_df
and the actual error appears to be related to index types that don't match:
ValueError: You are trying to merge on datetime64[ns] and object columns. If you wish to proceed you should use pd.concat
Replication:
• using the exogenous tutorial here https://nixtla.github.io/neuralforecast/examples/exogenous_variables.html
• replacing the .fit()
code chunk with .cross_validation(df=df, static_df=static_df, val_size=int(len(df) * .2))
Kin Gtz. Olivares
01/06/2023, 2:25 PMds
columns do not match in their types.
You would need to convert one of them using <http://pd.to|pd.to>_datetime
.Chris Gervais
01/06/2023, 2:39 PMValueError: You are trying to merge on datetime64[ns] and datetime64[ns, tzfile('/usr/share/zoneinfo/US/Eastern')] columns. If you wish to proceed you should use pd.concat
.cross_validation()
?Kin Gtz. Olivares
01/06/2023, 10:10 PMChris Gervais
01/08/2023, 7:57 PM.fit()
method works but .cross_validation()
fails, i think it's when merging the cv forecast dataframes. i can toss up an issue with replication steps if that's helpful?Kin Gtz. Olivares
01/08/2023, 7:57 PMChris Gervais
01/08/2023, 8:00 PMpl.Trainer
kwargs down from either the core NeuralForecast
class or the individual models, ie NHITS
?pl.Trainer(log_dir=..., auto_lr_find=...)
max_steps=1
• init the NeuralForecast
class and run .fit()
• deepcopy nf.models[0].trainer.datamodule
• init your own trainer class and train with pl.Trainer(...).fit(nf.models[0], datamodule=datamodule)