Skip to content

Neuralforecast

polars_ts.adapters.neuralforecast

Adapter for neuralforecast (N-BEATS, N-HiTS, PatchTST, etc.).

to_neuralforecast(df, target_col='y', id_col='unique_id', time_col='ds')

Convert a polars-ts DataFrame to neuralforecast format.

neuralforecast expects columns named exactly unique_id, ds, and y. This function renames columns as needed and ensures the time column is a proper datetime type.

from_neuralforecast(result_df, _target_col='y', id_col='unique_id', time_col='ds')

Convert neuralforecast output back to polars-ts format.

neuralforecast returns DataFrames with unique_id, ds, and model-named forecast columns. This renames back and selects the first forecast column as y_hat.