Help with Prediction results

Hey everybody,

I want to make predictions with HTM on real world data.
I want to predict energy consumption. My dataset contains the datetime and temperature, as well as the consumption itself.
I am doing cross validation in order to compare the results with other models. So I have trainings and test sets. And I disable learning when I am doing the prediction on the test set.
But now I am facing some problems.

I ran a (large) swarm with the following result:

  MODEL_PARAMS = \
{ 'aggregationInfo': { 'days': 0,
                       'fields': [],
                       'hours': 0,
                       'microseconds': 0,
                       'milliseconds': 0,
                       'minutes': 0,
                       'months': 0,
                       'seconds': 0,
                       'weeks': 0,
                       'years': 0},
  'model': 'HTMPrediction',
  'modelParams': { 'anomalyParams': { u'anomalyCacheRecords': None,
                                      u'autoDetectThreshold': None,
                                      u'autoDetectWaitRecords': None},
                   'clParams': { 'alpha': 0.01883125,
                                 'regionName': 'SDRClassifierRegion',
                                 'steps': '1',
                                 'verbosity': 0},
                   'inferenceType': 'TemporalMultiStep',
                   'sensorParams': { 'encoders': { '_classifierInput': { 'classifierOnly': True,
                                                                         'clipInput': True,
                                                                         'fieldname': 'consumption',
                                                                         'maxval': 617.76,
                                                                         'minval': 0.0,
                                                                         'n': 490,
                                                                         'name': '_classifierInput',
                                                                         'type': 'ScalarEncoder',
                                                                         'w': 21},
                                                   u'consumption': None,
                                                   u'datetime_dayOfWeek': None,
                                                   u'datetime_timeOfDay': { 'fieldname': 'datetime',
                                                                            'name': 'datetime',
                                                                            'timeOfDay': ( 21,
                                                                                           1.21875),
                                                                            'type': 'DateEncoder'},
                                                   u'datetime_weekend': None,
                                                   u'temperature': None},
                                     'sensorAutoReset': None,
                                     'verbosity': 0},
                   'spEnable': True,
                   'spParams': { 'boostStrength': 0.0,
                                 'columnCount': 2048,
                                 'globalInhibition': 1,
                                 'inputWidth': 0,
                                 'numActiveColumnsPerInhArea': 40,
                                 'potentialPct': 0.8,
                                 'seed': 1956,
                                 'spVerbosity': 0,
                                 'spatialImp': 'cpp',
                                 'synPermActiveInc': 0.05,
                                 'synPermConnected': 0.1,
                                 'synPermInactiveDec': 0.043918750000000006},
                   'tmEnable': True,
                   'tmParams': { 'activationThreshold': 14,
                                 'cellsPerColumn': 32,
                                 'columnCount': 2048,
                                 'globalDecay': 0.0,
                                 'initialPerm': 0.21,
                                 'inputWidth': 2048,
                                 'maxAge': 0,
                                 'maxSegmentsPerCell': 128,
                                 'maxSynapsesPerSegment': 32,
                                 'minThreshold': 10,
                                 'newSynapseCount': 20,
                                 'outputType': 'normal',
                                 'pamLength': 3,
                                 'permanenceDec': 0.1,
                                 'permanenceInc': 0.1,
                                 'seed': 1960,
                                 'temporalImp': 'cpp',
                                 'verbosity': 0},
                   'trainSPNetOnlyIfRequested': False},
  'predictAheadTime': None,
  'version': 1}

So now there are several things:

  1. When I just predict with this model Parameters i get the following result:

The HTM System is doing pretty much the naive prediction. But I thought it does not have the information of the consumption ( I mean they are not encoded). So how can the system know them?

  1. I want to add the temperature to the model, bc I know that there is a correlation of -0.9 between the consumption (which I want to predict) and the temperature. So in my understanding the temperature should be encoded, bc it has influence on the energy consumption.

So I ran another swarm to figure out the parameters for the temperature encoding.
My result was:

u'temperature': { 'clipInput': True,
                  'fieldname': 'temperature',
                  'maxval': 25.25,
                  'minval': -5.25,
                  'n': 387,
                  'name': 'temperature',
                   'type': 'ScalarEncoder',
                   'w': 21}},

And with a medium swarm I got the params for the consumption:

u'consumption': { 'clipInput': True,
                  'fieldname': 'consumption',
                  'maxval': 617.76,
                  'minval': 0.0,
                  'n': 521,
                  'name': 'consumption',
                  'type': 'ScalarEncoder',
                  'w': 21},

So what I have done, was just to add this to my model_params like this (just showing the sensor Params), while removing the timeOfDay:

'sensorParams': { 'encoders': { '_classifierInput': { 'classifierOnly': True,
                                                                         'clipInput': True,
                                                                         'fieldname': 'consumption',
                                                                         'maxval': 617.76,
                                                                         'minval': 0.0,
                                                                         'n': 521,
                                                                         'name': '_classifierInput',
                                                                         'type': 'ScalarEncoder',
                                                                         'w': 21},
                                                   u'consumption': { 'clipInput': True,
                                                                 'fieldname': 'consumption',
                                                                 'maxval': 617.76,
                                                                 'minval': 0.0,
                                                                 'n': 521,
                                                                 'name': 'consumption',
                                                                 'type': 'ScalarEncoder',
                                                                 'w': 21},
                                                   u'datetime_dayOfWeek': None,
                                                   u'datetime_timeOfDay': None, 
                                                   u'datetime_weekend': None,
                                                   u'temperature':{ 'clipInput': True,
                                                                    'fieldname': 'temperature',
                                                                    'maxval': 25.25,
                                                                    'minval': -5.25,
                                                                    'n': 387,
                                                                    'name': 'temperature',
                                                                    'type': 'ScalarEncoder',
                                                                    'w': 21}},
                                     'sensorAutoReset': None,
                                     'verbosity': 0},

Ok so now to the second problem: I get super weird results:

This is in nearly every test set. So either I get the naive predition or just zeros all the time.
What can be reasons for such a behavior?

I really neeeed some help. :see_no_evil: :sweat_smile:+
Thank you all very much.
Helena

I’m not familiar with NuPIC. But may you provide the SP/TM the anomaly score plot parameters and the ? Having all zero prediction may be caused by a NaN somewhere or the active threshold being too high.

oke first of all thanks a lot for your reply =)
But I do not understand exactly what you want… sorry :sweat_smile:

I am not doing anomly detection, just simple prediction… so I don’t have that score.
And well… I removed all the NaNs from my dataset, if this is your point (not sure).

As you can see, my activation threshold is 14:

this was the swarm result… maybe this is the problem… I don’t know :roll_eyes:
I can try to reduce it to maybe 10 and tell you wants happening =)
I’ll be back with the results in a few minutes =)

Sooo… I tried to reduce to activation threshold. And indeed: I get a prediction which is not zero :partying_face:
But now a few questions remain, because the results are still quite bad.

  1. Why does the HTM-System not learn, that the prediction of zeros is bad and bc of that changes the synapse structure?
  2. When I reduce the activation threshold, which other parameters do I have to update?
  3. How can I figure out a good value for these parameter(s)?

And in addition to these questions: whats about the other question from above:

This is this a mystery for me :sweat_smile:
Anyone an idea? =)

This type of logic is not built into nupic, and a prediction of a long series of zeros could make sense for some patterns.

For the other two questions, HTM school (youtube) should give you an understanding of how these parameters impact learning.

Also suggest HTM Studio may provide a quicker visual feedback loop when experimenting with these parameters.

Happy experimenting! :grin: