Predicting multiple steps into the future

Dear all,

I am testing NUPIC and I want to predict future values. I am using a similar script as the one in Hot Gym prediction.

Currently I have 400 rows of data. I run the script and the output on the csv gives me 400 rows of data.

However, I want to receive 402 rows of data, because I want to compare NUPIC predictions with future values that I will obtain in a few hours. I want to obtain the 401/402 row from the 399/400 value (step=2). Which parameters I need to change to obtain this? What represents the “predictAheadTime” parameter on the model params file?

Best regards,
José Santos

1 Like

If you are using the Hot Gym example, I believe it predicts one step into the future. The data is fed in at hourly intervals, so this is effectively predicting one hour into the future. To change this, you can update the swarm description:

Change this to:

"predictionSteps": [ 

Now it will swarm to get the best prediction 2 hours into the future, and return to you model params tuned for that.

You will probably also need to adjust your code that extracts the prediction from the result. In particular, this line:

Needs to be updated to read:

prediction = result.inferences["multiStepBestPredictions"][2]
1 Like

Hi rhyolight,

That’s not the issue I was mentioning on top. The prediction step I already changed and it works fine. My question is about the last predicted values of NUPIC, because I think that NUPIC doens’t give me the last two predicted values (T+1, T+2).

For example: on my understanding when I input into nupic the data value on T time it will predict the value of T+2 time if I define a step of 2, right? But on the excell I have only the prediction for the last value of my real data that was calculated on T Last-2, right?

What I want is to get the T Last+1 and the T Last+2, that should be calculated based on the last two values I input into NUPIC.

If I have 200 values of data (and a step of 2) by injecting the last value of the data I should have the 202 value ( = TLast +2). Right? Or NUPIC doens’t work like this?

Best regards,
José Santos

That’s correct.

Yes that sounds right.

Ok so try changing the clParams in the model params returned by the swarm to include 1 & 2 steps like this:

'clParams': { 
  'steps': '1,2',
1 Like

By doing the change on the clParams I get 1 and 2 step values?

The script for the hot gym does shifting when it writes the value on the excel?

Because I want to get future values that I don’t know. For example, if I have avg values per hour, and the last value of my data occured at 15:00 pm if I run NUPIC with a step of 2 I want to get the value at 17:00 pm that I don’t know yet.

Best regards,
José Santos

Yes you should. Did you try it?

Shifting is only done if you are plotting, not when writing to CSV:

You can easily change this so that shifting occurs all the time.

Yes, that’s what should be happening. Run it and let me know what you get?

Yes, but I only get on the excell the predictions for 1 step. I don’t have both…

Therefore, when I have these results (step 1):

It means that the prediction I have on: 2010-07-02 06:00:00 47.5 23.5 is for 2010-07-02 07:00:00. Am I correct?


Also, you are going to have to adjust the script to get the new prediction (for the 2nd step ahead) and deal with it (write it to your file). You’re not seeing it in your output file because the demo code was only handling one prediction.

If you want to send more than one prediction into the output, you’ll need to adjust here to send in multiple predictions to the writer:

Here to adjust the headers the writer is creating:

And here to adjust how the rows are written out to include the 2nd prediction:

Topic changed from “Prediction ahead time”.

Thank you rhyolight for the help! I was able to get both predictions and interpret the results.

Best regards,
José Santos

1 Like

We had initially tried the advice in this article in order to get our very first predictions from NuPIC, 1, 2 and 3 steps ahead, using sine wave but were stumped until receiving further encouragement from rhyolight. Just want to add to the above and explain that we (somewhat in desperation!) input 500,000 values of sine into the prediction (overkill no doubt) and were enheartened to see very accurate predictions coming from NuPIC at the tail end.

Thank you, Jose, for posting this question and many thanks to rhyolight for the push in the right direction!

Wow, I would not even have expected that NuPIC would predict a sine wave very well. Thanks for persisting!