M4
class will automatically download the complete M4 dataset and
process it.
It return three Dataframes: Y_df
contains the values for the target
variables, X_df
contains exogenous calendar features and S_df
contains static features for each time-series (none for M4). For this
example we will only use Y_df
.
If you want to use your own data just replace Y_df
. Be sure to use a
long format and have a simmilar structure than our data set.
unique_id | ds | y | |
---|---|---|---|
0 | M1 | 1970-01-01 00:00:00.000000001 | 8000.0 |
1 | M1 | 1970-01-01 00:00:00.000000002 | 8350.0 |
2 | M1 | 1970-01-01 00:00:00.000000003 | 8570.0 |
3 | M1 | 1970-01-01 00:00:00.000000004 | 7700.0 |
4 | M1 | 1970-01-01 00:00:00.000000005 | 7080.0 |
… | … | … | … |
11246406 | M9999 | 1970-01-01 00:00:00.000000083 | 4200.0 |
11246407 | M9999 | 1970-01-01 00:00:00.000000084 | 4300.0 |
11246408 | M9999 | 1970-01-01 00:00:00.000000085 | 3800.0 |
11246409 | M9999 | 1970-01-01 00:00:00.000000086 | 4400.0 |
11246410 | M9999 | 1970-01-01 00:00:00.000000087 | 4300.0 |
NeuralForecast.fit
method you can train a set of models to your dataset. You just have to
define the input_size
and horizon
of your model. The input_size
is
the number of historic observations (lags) that the model will use to
learn to predict h
steps in the future. Also, you can modify the
hyperparameters of the model to get a better accuracy.
core.NeuralForecast.save
method. This method uses
PytorchLightning save_checkpoint
function. We set save_dataset=False
to only save the model.
core.NeuralForecast.load
method, and
forecast AirPassenger
with the core.NeuralForecast.predict
function.
unique_id | ds | NHITS | |
---|---|---|---|
0 | 1.0 | 1960-01-31 | 422.038757 |
1 | 1.0 | 1960-02-29 | 424.678040 |
2 | 1.0 | 1960-03-31 | 439.538879 |
3 | 1.0 | 1960-04-30 | 447.967072 |
4 | 1.0 | 1960-05-31 | 470.603333 |
mae
).