darts icon indicating copy to clipboard operation
darts copied to clipboard

question: training the model to predict a single future step

Open zhoujs93 opened this issue 2 years ago • 3 comments

Is your feature request related to a current problem? Please describe. A clear and concise description of what the problem is.

Hi, i have a question, I was wondering how we would specify the training data or pass the data into model.fit() if we want to provide a sequence to predict a single step thats further out into the future ? My understanding right now is that given a input chunk length, we are predicting the next output_chunk_length into the future. For example, given input_chunk_length = 100, and output_chunk_length=1, we are predicting the next step into the series.

Is there a way for us to predict a step into the future without changing the output_chunk_length ? For example, using input_chunk_length=100 and output_chunk_length=1 but training the model to predict the 100th step into the future ?

Describe proposed solution A clear and concise description of what the library should provide to solve missing functionality.

Providing the option to specify the stride_step if needed, similar to the forecast_horizon method for models

Describe potential alternatives A clear and concise description of any alternative solutions or existing features that might solve it.

There is also the function of fit_with_dataset for this, but i think providing the stride_step argument in model.fit() would be better.

Additional context Add any other context or screenshots about the feature request here.

zhoujs93 avatar Dec 31 '23 01:12 zhoujs93

Hi @zhoujs93,

At the moment, the feature you are requesting can be obtained by combining the ShiftedDataset (doc, using the sub-class corresponding to the model and setting the shift parameter) with fit_from_dataset().

@dennisbader WDYT about adding this new argument? I think that I would rather not, since this argument would be used only by deep learning models.

madtoinou avatar Jan 01 '24 17:01 madtoinou

Hi @zhoujs93,

At the moment, the feature you are requesting can be obtained by combining the ShiftedDataset (doc, using the sub-class corresponding to the model and setting the shift parameter) with fit_from_dataset().

@dennisbader WDYT about adding this new argument? I think that I would rather not, since this argument would be used only by deep learning models.

Hi there, thanks for the response, I also noticed that there is a fit_from_dataset method, but it seems like there are many choices.

As for me, I would like to train my model to simply take an input length of 100, and to have it trained to predict the value after skipping 100 time steps. so for example, given an array, it would take indexes [0, ...., 100] and then predict the [200th] value.

I believe this should be the implementation:

      self.ds = GenericShiftedDataset(
            target_series=target_series,
            covariates=covariates,
            input_chunk_length=100,
            output_chunk_length=1,
            shift=100,
            shift_covariates=False,
            max_samples_per_ts=max_samples_per_ts,
            covariate_type=CovariateType.PAST,
            use_static_covariates=use_static_covariates,
        )

However, I also want to verify this for the prediction step as well. Would something like this be correct ?

input_chunk_len = model_configs['input_chunk_length']
output_chunk_len = model_configs['output_chunk_length']
shift = 100
for i in tqdm(range(input_chunk_len, n - shift)):
    ds_te = PastCovariatesInferenceDataset(
        target_series = test_set[0][i - input_chunk_len:i],
        covariates = cov_te_set[0][i-input_chunk_len:i],
        n = 1,
        stride = 0,
        input_chunk_length = 100,
        output_chunk_length = 1,
        use_static_covariates = False
    )
    pred = forecasting_model.predict_from_dataset(n = 1, input_series_dataset = ds_te)

It is hard to verify the correct since the time index of predicted value seems to be the next time step after the input sequence, as opposed to shifting the time step as well.

Hope I make sense about this and please let me know if you need clarifications, thanks !

zhoujs93 avatar Jan 03 '24 15:01 zhoujs93

@dennisbader Hi, thanks for adding this feature. just wondering if theres any remaining steps for it to be pushed into the main branch and how we could install the most recently updated version using pip install.

Thanks !

zhoujs93 avatar Feb 03 '24 00:02 zhoujs93