Nixtla / neuralforecast

Scalable and user friendly neural :brain: forecasting algorithms.
https://nixtlaverse.nixtla.io/neuralforecast
Apache License 2.0
2.98k stars 342 forks source link

NeuralForecast.fit() got an unexpected keyword argument 'test_size' #1029

Closed stephanielees closed 1 month ago

stephanielees commented 3 months ago

What happened + What you expected to happen

What happened: In the documentation of the fit method of NHITS, there are arguments val_size and test_size. However, when I try to specify the test_size, I got an error message like this:

NeuralForecast.fit() got an unexpected keyword argument 'test_size'

What you expected to happen The fit method should accept test_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.2

Reproduction 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.

marcopeix commented 2 months 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!