wilsonrljr/sysidentpy

Forecasting with unseen inputs and forecast model generation

Closed this issue · 3 comments

The predict function input arguments are X_valid and y_valid. How can I forecast with my trained model if I don't have output (y_valid) yet?

Using the simulation function, can it be used for forecasting by directly referencing the trained model regressors?

The package worked perfectly for my data, and I would like to use it for real-time workflow. This involves training validation-forecasting-updating of the model in real-time.

As new data is streamed, can I initialize with the previous model and re-regress to update the model's parameters?
Thank you very much

Hi @rabiu42000 , thanks you for bringing this to my attention, so I can make the documentation clearer.

The predict function input arguments are X_valid and y_valid. How can I forecast with my trained model if I don't have output (y_valid) yet?

You just need to pass the initial conditions to the model. We give some examples using y_valid with the same shape of the input, but this is not necessary because we are using free run simulation by default. In this case, if your model is something like ay(k-1) + by(k-2) - c*x(k-1), the maximum lag is 2 and you just need to pass two initial conditions, even if your input have 50 samples. If you are working with a time series, for example, and want to predict the next days, you can use the last two days as initial conditions. In this case, model.predict(X_new_data, y_new_data) only requires that y_new_data contains the initial condition. Note: The initial conditions depends on whats you want to do with your model, but you just need the initial conditions.

You can pass only the initial conditions even in validation phase. In the fit function, x and y must have the same size, but in the predict function y just requires the initial conditions (if you are using the free run simulation, the default option. For n_steps_ahead y must have the real values at each cicle).

Using the simulation function, can it be used for forecasting by directly referencing the trained model regressors?

Yes. If you already have a predefined model you can just use the simulation function. You can use it even if you have only the regressors of the model, because you can set estimate_parameter=True and the parameter will be estimated in the process.

But you can do that using different methods. You could also get the model using the fit function and save it using joblib or pickle file, for example.

As new data is streamed, can I initialize with the previous model and re-regress to update the model's parameters?

Yes, you can do that. If you have the model regressors, you can use the simulation function to re-estimate the model's parameters and make the prediction. In this case, the model regressors do not change, only the parameters. Applying the fit function could change your model regressors due the new data, but using the simulation function only the parameters are changed.

Let me know if you need anything else

Hi @rabiu42000! I'm closing this issue since I think I've answered your questions, but feel free to comment here or contact me by mail or social media if you have any other question!

I see that i need to pass initial condition for y but where are the initial conditions for x? Must be included in the Xnew_data?
Let for example a model with lag 2 in both x and y. At time t i have my y past of ypast-1 and ypast-2 and of course i know the past inputs xpast-1, xpast-2. I wan to predict with new x valuew for ex 4 timesteps xnew1, xnew2,xnew3, xnew4. So my xnew y inital can be [ypast-2, ypast-1] and my xnew?
[xnew1, xnew2,xnew3, xnew4]
or [xpast-2, xpast-1, xnew1, xnew2,xnew3, xnew4]

Please note that i am talking about the Neural NARX