numenta / nupic-legacy

Numenta Platform for Intelligent Computing is an implementation of Hierarchical Temporal Memory (HTM), a theory of intelligence based strictly on the neuroscience of the neocortex.
http://numenta.org/
GNU Affero General Public License v3.0
6.33k stars 1.56k forks source link

Anomaly likelihoods with swarmed parameters #3774

Open wmbm opened 6 years ago

wmbm commented 6 years ago

Hello everyone,

Using the default model parameters for an OPF model, I get no complaints extracting anomalies from my data. Running a swarmed parameters on my dataset causes the below error. I can get predictions and anomaly scores but anomaly likelihoods create this error.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-4cb531be818f> in <module>()
     49 
     50         anomaly_Likelihood_r = anomaly_likelihood_helper.anomalyProbability(
---> 51             modelInput["value"], anomaly_score_r, modelInput["dttm"]
     52         )
     53 

/usr/local/lib/python2.7/dist-packages/nupic/algorithms/anomaly_likelihood.pyc in anomalyProbability(self, value, anomalyScore, timestamp)
    384         _, _, self._distribution = estimateAnomalyLikelihoods(
    385           self._historicalScores,
--> 386           skipRecords=numSkipRecords)
    387 
    388       likelihoods, _, self._distribution = updateAnomalyLikelihoods(

/usr/local/lib/python2.7/dist-packages/nupic/algorithms/anomaly_likelihood.pyc in estimateAnomalyLikelihoods(anomalyScores, averagingWindow, skipRecords, verbosity)
    458     anomalyScores,
    459     windowSize = averagingWindow,
--> 460     verbosity = verbosity)
    461   s = [r[2] for r in aggRecordList]
    462   dataValues = numpy.array(s)

/usr/local/lib/python2.7/dist-packages/nupic/algorithms/anomaly_likelihood.pyc in _anomalyScoreMovingAverage(anomalyScores, windowSize, verbosity)
    670 
    671     avg, historicalValues, total = (
--> 672       MovingAverage.compute(historicalValues, total, record[2], windowSize)
    673       )
    674 

/usr/local/lib/python2.7/dist-packages/nupic/utils.pyc in compute(slidingWindow, total, newVal, windowSize)
     79 
     80     slidingWindow.append(newVal)
---> 81     total += newVal
     82     return float(total) / len(slidingWindow), slidingWindow, total
     83 

TypeError: unsupported operand type(s) for +=: 'float' and 'NoneType'

My guess so far would be that I haven't correctly defined my swarming definition "search_def.json", but I'm really not too sure.

{
  "includedFields": [
    {
      "fieldName": "dttm", 
      "fieldType": "datetime"
    }, 
    {
      "fieldName": "value", 
      "fieldType": "float"
    }
  ], 
  "streamDef": {
    "info": "test", 
    "version": 1, 
    "streams": [
      {
        "info": "sim_data_mp.csv", 
        "source": "file://myswarm/data/sim_data_mp.csv", 
        "columns": [
          "*"
        ], 
        "last_record": 100
      }
    ], 
    "aggregation": {
      "hours": 1, 
      "microseconds": 0, 
      "seconds": 0, 
      "fields": [
        [
          "value", 
          "sum"
        ], 

        [
          "dttm", 
          "first"
        ]
      ], 
      "weeks": 0, 
      "months": 0, 
      "minutes": 0, 
      "days": 0, 
      "milliseconds": 0, 
      "years": 0
    }
  }, 
  "inferenceType": "TemporalAnomaly", 
  "inferenceArgs": {
    "predictionSteps": [
      1
    ], 
    "predictedField": "value"
  }, 
  "iterationCount": -1, 
  "swarmSize": "medium"
}

Any thoughts about where this is coming from?

Cheers,

rhyolight commented 6 years ago

Please tell me what version of nupic you are running.

wmbm commented 6 years ago

nupic 1.0.4.dev0 nupic.bindings 1.0.0

rhyolight commented 6 years ago

Is there any way you could isolate this error with as little data as possible and tarball up a clean code example the throws the error?

carlospc89 commented 5 years ago

Did anyone follow up this issue?