pip install nupic
from nupic.frameworks.opf.model_factory import ModelFactory
model_params = {
'model': "HTMPrediction",
'version': 1,
'predictAheadTime': None,
'modelParams': {
'clParams': {
'regionName': 'SDRClassifierRegion',
'clVerbosity': 0,
'alpha': 0.001,
'steps': '1'
},
'spParams': {
'spVerbosity': 0,
'globalInhibition': 1,
'columnCount': 2048,
'inputWidth': 0,
'numActiveColumnsPerInhArea': 40,
'seed': 1956,
'potentialPct': 0.85,
'synPermConnected': 0.1,
'synPermActiveInc': 0.0001,
'synPermInactiveDec': 0.0005
},
'tmParams': {
'tmVerbosity': 0,
'columnCount': 2048,
'cellsPerColumn': 32,
'inputWidth': 2048,
'seed': 1960,
'temporalImp': 'cpp',
'newSynapseCount': 20,
'maxSynapsesPerSegment': 32,
'maxSegmentsPerCell': 128,
'initialPerm': 0.21,
'permanenceInc': 0.1,
'permanenceDec': 0.1,
'globalDecay': 0.0,
'maxAge': 0,
'minThreshold': 12,
'activationThreshold': 16,
'outputType': 'normal',
'pamLength': 3
}
}
}
model = ModelFactory.create(model_params)
model.enableInference({"predictedField": "data"})
model.initialize()
result = model.run({"data": 1})
prediction = result.inferences['multiStepBestPredictions'][1]