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.34k stars 1.56k forks source link

Anomaly detection error: TypeError: unsupported operand type(s) for +=: 'float' and 'NoneType' #3775

Closed tjdurant closed 7 years ago

tjdurant commented 7 years ago

Hello,

I am running through the tutorial from (https://github.com/numenta/nupic/tree/master/examples/opf/clients/hotgym/anomaly/one_gym). I am getting the error below. I am running CentOS7, Python 2.7.13 :: Anaconda 4.3.0 (64-bit),

$ python run_anomaly.py

Gives this output:

Starts a NuPIC model from the model params returned by the swarm
and pushes each line of input from the gym into the model. Results
are written to an output file (default) or plotted dynamically if
the --plot option is specified.

Creating model from rec-center-hourly...
Importing model params from model_params.rec_center_hourly_model_params
Preparing to output rec-center-hourly data to rec-center-hourly_out.csv
Read 100 lines...
Read 200 lines...
Read 300 lines...
Traceback (most recent call last):
  File "run_anomaly.py", line 151, in <module>
    runModel(GYM_NAME, plot=plot)
  File "run_anomaly.py", line 141, in runModel
    runIoThroughNupic(inputData, model, gymName, plot)
  File "run_anomaly.py", line 122, in runIoThroughNupic
    output.write(timestamp, consumption, prediction, anomalyScore)
  File "/root/nupic/swarm/nupic_anomaly_output.py", line 93, in write
    value, anomalyScore, timestamp
  File "/root/anaconda2/lib/python2.7/site-packages/nupic/algorithms/anomaly_likelihood.py", line 386, in anomalyProbability
    skipRecords=numSkipRecords)
  File "/root/anaconda2/lib/python2.7/site-packages/nupic/algorithms/anomaly_likelihood.py", line 460, in estimateAnomalyLikelihoods
    verbosity = verbosity)
  File "/root/anaconda2/lib/python2.7/site-packages/nupic/algorithms/anomaly_likelihood.py", line 672, in _anomalyScoreMovingAverage
    MovingAverage.compute(historicalValues, total, record[2], windowSize)
  File "/root/anaconda2/lib/python2.7/site-packages/nupic/utils.py", line 81, in compute
    total += newVal
TypeError: unsupported operand type(s) for +=: 'float' and 'NoneType'
rhyolight commented 7 years ago

Someone else just reported this in https://github.com/numenta/nupic/issues/3774.

You are using Anaconda? (If so, we don't support it yet, but you can help).

tjdurant commented 7 years ago

Yea, we're using Anaconda, but we use pip to install it into the virtual environment:

$ conda list

nupic                     1.0.3                     <pip>
nupic.bindings            1.0.0                     <pip>

I saw on #3774 that he is able to get anomaly scores, but I don't even get those. I'm not entirely sure about where my problem is in relation to his, so I'll defer to you if you think ours are sufficiently similar that I can just follow #3774 for a solution.

Thanks! Thomas

rhyolight commented 7 years ago

I don't trust NuPIC on Anaconda because we don't have a CI build for that environment yet. So I would just assume it will not work properly on Anaconda at this point. Will defer further tech discussion to #3774. Thanks for the report.