Not Getting Anomaly Results

Hi,

I’ve got a model that takes 3 inputs: timestamp, upstream (where vehicles start) and downstream (where vehicles end). I’ve set the predictedField field to downstream. The idea is to measure traffic flow at both ends of a stretch of road, feed them into a HTM model and determine if there’s anomalous traffic flow on that section of road. The problem is that my anomaly results are mostly 0 for the entire dataset, despite large differences between predicted output and actual output:


Here’s my modelParams:

{   'aggregationInfo': {   'days': 0,
                           'fields': [],
                           'hours': 0,
                           'microseconds': 0,
                           'milliseconds': 0,
                           'minutes': 0,
                           'months': 0,
                           'seconds': 0,
                           'weeks': 0,
                           'years': 0},
    'model': 'CLA',
    'modelParams': {   'anomalyParams': {   u'anomalyCacheRecords': None,
                                            u'autoDetectThreshold': None,
                                            u'autoDetectWaitRecords': 5030},
                       'clParams': {   'alpha': 0.035828933612158,
                                       'clVerbosity': 0,
                                       'regionName': 'CLAClassifierRegion',
                                       'steps': '1'},
                       'inferenceType': 'TemporalAnomaly',
                       'sensorParams': {   'encoders': {   'downstream': {   'clipInput': True,
                                                                             'fieldname': 'downstream',
                                                                             'maxval': 150,
                                                                             'minval': 0.0,
                                                                             'n': 600,
                                                                             'name': 'downstream',
                                                                             'type': 'ScalarEncoder',
                                                                             'w': 21},
                                                           'timestamp_timeOfDay': {   'fieldname': 'timestamp',
                                                                                      'name': 'timestamp_timeOfDay',
                                                                                      'timeOfDay': (   51,
                                                                                                       9.49),
                                                                                      'type': 'DateEncoder'},
                                                           'timestamp_weekend': {   'fieldname': 'timestamp',
                                                                                    'name': 'timestamp_weekend',
                                                                                    'type': 'DateEncoder',
                                                                                    'weekend': (   51,
                                                                                                   9)},
                                                           'upstream': {   'clipInput': True,
                                                                           'fieldname': 'upstream',
                                                                           'maxval': 150,
                                                                           'minval': 0.0,
                                                                           'n': 600,
                                                                           'name': 'upstream',
                                                                           'type': 'ScalarEncoder',
                                                                           'w': 21}},
                                           'sensorAutoReset': None,
                                           'verbosity': 0},
                       'spEnable': True,
                       'spParams': {   'columnCount': 2048,
                                       'globalInhibition': 1,
                                       'inputWidth': 0,
                                       'maxBoost': 1.0,
                                       'numActiveColumnsPerInhArea': 40,
                                       'potentialPct': 0.8,
                                       'seed': 1956,
                                       'spVerbosity': 0,
                                       'spatialImp': 'cpp',
                                       'synPermActiveInc': 0.003,
                                       'synPermConnected': 0.2,
                                       'synPermInactiveDec': 0.0005},
                       'tpEnable': True,
                       'tpParams': {   'activationThreshold': 13,
                                       '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': 5,
                                       'permanenceDec': 0.1,
                                       'permanenceInc': 0.1,
                                       'seed': 1960,
                                       'temporalImp': 'cpp',
                                       'verbosity': 0},
                       'trainSPNetOnlyIfRequested': False},
    'predictAheadTime': None,
    'version': 1}

My code is here: https://github.com/JonnoFTW/htm-models-adelaide/blob/master/engine/index.py#L395-L468
Although it basically feeds the data I’ve linked below into an OPF model and puts the output into the nupic_anomaly_output plotter.

Here’s my data: https://www.dropbox.com/s/2tvltfacwct6lsn/readings.csv.zip?dl=0

Hi Jonathan,
Did you swarm to get these model params? I would recommend trying the params from getScalarMetricWithTimeOfDayAnomalyParams(); an example invocation is here.

Cheers,
Alex

I didn’t swarm to get the model params, since I am using the provided model
parameters (
https://github.com/numenta/nupic/blob/master/src/nupic/frameworks/opf/common_models/anomaly_params_random_encoder/best_single_metric_anomaly_params_cpp.json)
Although my clParams.regionName is ‘CLAClassifierRegion’ (the file
lists "SDRClassifierRegion"), would that make a difference?

The classifier region name shouldn’t matter (in prediction and anomaly detection scenarios). The one difference I notice from the detector in NAB is modelParams["modelParams"]["tpParams"]["pamLength"] = 3, but here it’s 5. This param will have influence the anomaly scores.

Is there more data you’re not showing before these plots? The anomaly scores should be high and erratic when initially learning a data stream.