Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forecasting next couple time steps #16

Open
TiaHao opened this issue Dec 17, 2024 · 3 comments
Open

forecasting next couple time steps #16

TiaHao opened this issue Dec 17, 2024 · 3 comments

Comments

@TiaHao
Copy link

TiaHao commented Dec 17, 2024

Dear developer,

I am currently using the NGC framework to find the GC relationship and doing next 1 time step forecasting, but now I would like to extend to next 3-6 time steps forecasting, would this be possible to modify these model structures for this purpose? thank you!

@iancovert
Copy link
Owner

Yes, this should be possible. The things you'll need to change include 1) the model's __init__ function to ensure it outputs predictions for multiple time steps, and 2) how the loss is calculated. Otherwise, the same idea of sparsifying each network via its input layer seems valid.

For the model setup, you can see the cMLP source code here for example. The forward function applies a series of fully-connected layers (implemented via Conv1d layers to do so in parallel for all time steps), including a final layer that outputs a single value per time step. To change this, you would modify the part of this line with hidden[1:] + [1] to hidden[1:] + [num_steps]. You'll also want to make sure the cMLP class, which wraps the MLP class, concatenates the outputs properly here.

For the loss calculation, you'll want to modify the part of the training code that handles the forecasting MSE. For the cMLP's GISTA training, it's handled here. The first argument to loss_fn is the predictions, which should be handled by your changes above. The second argument is the targets, and you'll want to rearrange the time series differently than X[:, lag:, i:i+1] to have targets for the multiple forecasts.

Let me know if this makes sense.

@TiaHao
Copy link
Author

TiaHao commented Dec 18, 2024

thanks for your timely reply! Yes it makes sense a lot. I am also modifying it as you suggested. However, I notice that the computational time of multi-step forecasting of cMLP dramatically increases, so I am thinking if this model structure is not very suitable for multi-step forecasting purpose, especially if I only care about identifying GC relationship and forecasting for 1 feature.

@iancovert
Copy link
Owner

That's interesting, let me think about whether it makes sense for the forecasting time to dramatically increase...I suppose that the computation for each prediction has more FLOPs in the second matmul (implemented as a convolution), so this could perhaps as much as double the computation time. Is the slowdown you're seeing consistent with that, or even worse?

If you're only interested in identifying GC relationships when forecasting a single variable, you're right that you could simplify the problem. Rather than fitting an entire cMLP with one network per variable, you could fit a single MLP for the variable you want to forecast, and train it with the same regularization approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants