Closed stephanielees closed 1 month ago
Hello! The fit
method does not have the test_size
parameter, but it has the val_size
parameter for a validation set (see here).
Otherwise, you can use cross-validation and specify both a val_size
and test_size
.
In your case, if you only want to fit and predict over 743 time steps, just remove them from your training data, make predictions, and compare them to the actual values.
I hope this helps!
What happened + What you expected to happen
What happened: In the documentation of the
fit
method of NHITS, there are argumentsval_size
andtest_size
. However, when I try to specify thetest_size
, I got an error message like this:What you expected to happen The
fit
method should accepttest_size
since this variable is going to be used for predicting.Versions / Dependencies
I'm using Kaggle notebook, and the
neuralforecast
library I'm using is of version 1.7.2Reproduction script
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import torch
from torch import optim, nn, utils, Tensor
import lightning.pytorch as pl
from pytorch_lightning import LightningModule, LightningDataModule
from neuralforecast import NeuralForecast
from neuralforecast.tsdataset import TimeSeriesDataset
from neuralforecast.models import NHITS
trainer_kwargs = dict(accelerator='gpu', devices=2, strategy='ddp_notebook')
model = NHITS(h=743, input_size=743*2, start_padding_enabled=True, interpolation_mode='cubic',
batch_size=128, learning_rate=2*1e-3, **trainer_kwargs)
fcst = NeuralForecast(models=[model], freq='h')
fcst.fit(pd.DataFrame({'unique_id': df_train.unique_id, 'ds': df_train.DateTime, 'y': df_train.Renewable}),
test_size=743,
verbose=True)
Issue Severity
High: It blocks me from completing my task.