Hi Matt and everybody,
So I just got NuPIC running without the datetime column or date encoder, and I want to make sure I’m doing it in a viable way (which I may well not be). Here are the changes I made to the runIoThroughNupic function in the run.py file. I basically just commented out anything with ‘timestamp’. When I removed ‘timestamp’ from the output.write() function I got an error for missing argument, so instead of deleting it outright I just replaced it with a blank space ‘___’. I can’t imagine this is the best way to do this, just a quick patch to get it running, which it did at least.
def runIoThroughNupic(inputData, model, gymName, plot):
"""
Handles looping over the input data and passing each row into the given model
object, as well as extracting the result object and passing it into an output
handler.
:param inputData: file path to input data CSV
:param model: OPF Model object
:param gymName: Gym name, used for output handler naming
:param plot: Whether to use matplotlib or not. If false, uses file output.
"""
inputFile = open(inputData, "rb")
csvReader = csv.reader(inputFile)
# skip header rows
csvReader.next()
csvReader.next()
csvReader.next()
shifter = InferenceShifter()
if plot:
output = nupic_anomaly_output.NuPICPlotOutput(gymName)
else:
output = nupic_anomaly_output.NuPICFileOutput(gymName)
counter = 0
for row in csvReader:
counter += 1
if (counter % 100 == 0):
print "Read %i lines..." % counter
#timestamp = datetime.datetime.strptime(row[0], DATE_FORMAT)
consumption = float(row[0]) #float(row[1])
result = model.run({
#"timestamp": timestamp,
"kw_energy_consumption": consumption
})
if plot:
result = shifter.shift(result)
prediction = result.inferences["multiStepBestPredictions"][1]
anomalyScore = result.inferences["anomalyScore"]
output.write('___', consumption, prediction, anomalyScore) #(timestamp, consumption, prediction, anomalyScore)
inputFile.close()
output.close()
I also deleted the date encoders from the model_params.py file, which now looks like this. Is this how you’d actually do this? Also I’m sure there’s a better way to post cost I just forget what it is, so if there’s a preferred way to view please let me know and I’ll have it up. Thanks again!!
MODEL_PARAMS = \
{ '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': None},
'clParams': { 'alpha': 0.01962508905154251,
'verbosity': 0,
'regionName': 'SDRClassifierRegion',
'steps': '1'},
'inferenceType': 'TemporalAnomaly',
'sensorParams': { 'encoders': { '_classifierInput': { 'classifierOnly': True,
'clipInput': True,
'fieldname': 'kw_energy_consumption',
'maxval': 1900.0,
'minval': 250.0,
'n': 115,
'name': '_classifierInput',
'type': 'ScalarEncoder',
'w': 21},
u'kw_energy_consumption': { 'clipInput': True,
'fieldname': 'kw_energy_consumption',
'maxval': 1900.0,
'minval': 250.0,
'n': 29,
'name': 'kw_energy_consumption',
'type': 'ScalarEncoder',
'w': 21}},
'sensorAutoReset': None,
'verbosity': 0},
'spEnable': True,
'spParams': { 'columnCount': 2048,
'globalInhibition': 1,
'inputWidth': 0,
'maxBoost': 2.0,
'numActiveColumnsPerInhArea': 40,
'potentialPct': 0.8,
'seed': 1956,
'spVerbosity': 0,
'spatialImp': 'cpp',
'synPermActiveInc': 0.05,
'synPermConnected': 0.1,
'synPermInactiveDec': 0.08568228006654939},
'tpEnable': True,
'tpParams': { 'activationThreshold': 12,
'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': 1,
'permanenceDec': 0.1,
'permanenceInc': 0.1,
'seed': 1960,
'temporalImp': 'cpp',
'verbosity': 0},
'trainSPNetOnlyIfRequested': False},
'predictAheadTime': None,
'version': 1}