What does one step ahead prediction mean in the Sine Wave prediction example?

In the sine wave prediction example, Matt says that the model is predicting one step ahead. But what does one step ahead mean? Is it predicting the sine wave for the next value of the angle?
Also I have noticed that you are passing sine_values from the manually generated sine wave as a parameter in model.run to get the predictions. But what if I want to predict the value of the sine wave based on the value of the angle?

Yes.

You could add the angle to the encoded input if you want, but I don’t think it would help. Let’s try and find out.

I’ve pushed my generated model to this branch so you can see it. Here are the sine wave encoder params:


We can add another encoder here for the angle, like this:

'sensorParams': {
  'encoders': {
    u'angle': {
      'clipInput': True,
      'fieldname': 'angle',
      'maxval': 180.0,
      'minval': 0.0,
      'n': 396,
      'name': 'angle',
      'type': 'ScalarEncoder',
      'w': 21
    },
    u'sine': {
      'clipInput': True,
      'fieldname': 'sine',
      'maxval': 1.0,
      'minval': -1.0,
      'n': 396,
      'name': 'sine',
      'type': 'ScalarEncoder',
      'w': 21
    }
  },
  'sensorAutoReset': None,
  'verbosity': 0
},

We then also must modify some other code to add the data to the rows we’re sending NuPIC. [Here is the whole diff] (https://github.com/rhyolight/nupic.examples/compare/tmp-example) (this only works with NuPIC 0.7.0.dev0, sorry.) The predictions are almost identical. The reason is that the angle, which simply accumulates over time, does not contribute to the value of the sine wave. All the information needed to predict this pattern is within the sine value over time. The accumulating angle does not contribute to the prediction at all.

2 Likes

@kaustabpal Did this help? Do you have any more questions?

2 Likes

In the sine wave prediction example, as you can see in the picture, the predicted value is either the same as the original value or it’s one step behind the original value. So I was having trouble understanding whether the HTM model was really predicting or not. But then I realized since the values in sine wave are varying too much, that’s why the model was still in the learning phase.
To help myself understand the concepts better I manually created a sawtooth wave and used the HTM model to predict two steps ahead and it worked perfectly. Below is the output.

1 Like

I actually meant if I have two columns: column A and column B, I would like to predict the values of column B based on the value of column A. i.e. I would be passing the values of column A in the model.run and it will return the predicted value of column B.
One use case for this might be, suppose I have a robot that does a specific task at a specific time. So I will pass the time in the HTM and get the task the robot is supposed to perform as output.
is this possible to implement something like this using HTM?

You can only do this if you pass both A and B values into the model. It can’t predict the value of something it never sees a representation of.

1 Like

I guess I will have to add another encoder like you showed above to achieve this. I will try this and let you know. Thanks a lot for your support.

1 Like

Ok, as long as you understand this is just an exercise. It will not improve the results. You know what would improve the results? If you encoded a timestamp that cycled daily with the sine curve. :wink:

2 Likes

How do I install NuPIC 0.7.0.dev0 and when can we expect an official release?

Checkout out or download the latest source code from git or github. Then from repo root simply run python setup.py install --user.

Hopefully I’ll release 0.7.0 later today, so you could just wait.

I have followed the changes, however I am getting this error. I think something need to be changed in the nupic_output.py however I can’t figure out what needs to be changed. Please help.

Did you run python generate_data.py?