NuPIC  0.2.7.dev0
Numenta Platform for Intelligent Computing
 All Classes Namespaces Files Functions Variables Pages
Public Member Functions | List of all members
Model Class Reference

This is the base class that all OPF Model implementations should subclass. More...

Inherits object.

Inherited by CLAModel.

Public Member Functions

def __init__
 Model constructor. More...
 
def run
 Run one iteration of this model. More...
 
def finishLearning
 Place the model in a permanent "finished learning" mode. More...
 
def resetSequenceStates
 Signal that the input record is the start of a new sequence. More...
 
def getFieldInfo
 Return the sequence of FieldMetaInfo objects specifying the format of Model's output. More...
 
def setFieldStatistics
 Propagate field statistics to the model in case some of its machinery needs it. More...
 
def getRuntimeStats
 Get runtime statistics specific to this model, i.e. More...
 
def getInferenceType
 Common learning/inference methods. More...
 
def enableLearning
 Turn Learning on for the current model. More...
 
def disableLearning
 Turn Learning off for the current model. More...
 
def isLearningEnabled
 Return the Learning state of the current model. More...
 
def enableInference
 Enable inference for this model. More...
 
def getInferenceArgs
 Return the dict of arguments for the current inference mode. More...
 
def disableInference
 Turn Inference off for the current model. More...
 
def isInferenceEnabled
 Return the inference state of the current model. More...
 
def save
 Implementation of common save/load functionality. More...
 
def load
 Load saved model. More...
 

Detailed Description

This is the base class that all OPF Model implementations should subclass.

It includes a number of virtual methods, to be overridden by subclasses, as well as some shared functionality for saving/loading models

Constructor & Destructor Documentation

def __init__ (   self,
  inferenceType 
)

Model constructor.

Parameters
inferenceType(nupic.frameworks.opf.opfutils.InferenceType) A value that specifies the type of inference (i.e. TemporalNextStep, Classification, etc.).

Member Function Documentation

def disableInference (   self)

Turn Inference off for the current model.

def disableLearning (   self)

Turn Learning off for the current model.

def enableInference (   self,
  inferenceArgs = None 
)

Enable inference for this model.

Parameters
inferenceArgs(dict) A dictionary of arguments required for inference. These depend on the InferenceType of the current model
def enableLearning (   self)

Turn Learning on for the current model.

def finishLearning (   self)

Place the model in a permanent "finished learning" mode.

In such a mode the model will not be able to learn from subsequent input records.

NOTE: Upon completion of this command, learning may not be resumed on the given instance of the model (e.g., the implementation may optimize itself by pruning data structures that are necessary for learning).

def getFieldInfo (   self,
  includeClassifierOnlyField = False 
)

Return the sequence of FieldMetaInfo objects specifying the format of Model's output.

 This may be different than the list of FieldMetaInfo objects supplied at
 initialization (e.g., due to the transcoding of some input fields into
 meta-fields, such as datetime -> dayOfWeek, timeOfDay, etc.).
Parameters
includeClassifierOnlyField(bool) If True, any field which is only sent to the classifier (i.e. not sent in to the bottom of the network) is also included
Returns
(list<nupic.data.fieldmeta.FieldMetaInfo>) List of FieldMetaInfo objects.
def getInferenceArgs (   self)

Return the dict of arguments for the current inference mode.

Returns
(dict) The arguments of the inference mode
def getInferenceType (   self)

Common learning/inference methods.

Return the InferenceType of this model. This is immutable.

Returns
(nupic.frameworks.opf.opfutils.InferenceType) An inference type
def getRuntimeStats (   self)

Get runtime statistics specific to this model, i.e.

activeCellOverlapAvg.

Returns
(dict) A {statistic names: stats} dictionary
def isInferenceEnabled (   self)

Return the inference state of the current model.

Returns
(bool) The inference state
def isLearningEnabled (   self)

Return the Learning state of the current model.

Returns
(bool) The learning state
def load (   cls,
  savedModelDir 
)

Load saved model.

Parameters
savedModelDir(string) Directory of where the experiment is to be or was saved
Returns
(Model) The loaded model instance
def resetSequenceStates (   self)

Signal that the input record is the start of a new sequence.

def run (   self,
  inputRecord 
)

Run one iteration of this model.

Parameters
inputRecord(object) A record object formatted according to nupic.data.record_stream.RecordStreamIface.getNextRecord() or nupic.data.record_stream.RecordStreamIface.getNextRecordDict() result format.
Returns
(nupic.frameworks.opf.opfutils.ModelResult) An ModelResult namedtuple. The contents of ModelResult.inferences depends on the the specific inference type of this model, which can be queried by getInferenceType()
def save (   self,
  saveModelDir 
)

Implementation of common save/load functionality.

Save the model in the given directory.

Parameters
saveModelDir(string) Absolute directory path for saving the model. This directory should only be used to store a saved model. If the directory does not exist, it will be created automatically and populated with model data. A pre-existing directory will only be accepted if it contains previously saved model data. If such a directory is given, the full contents of the directory will be deleted and replaced with current model data.
def setFieldStatistics (   self,
  fieldStats 
)

Propagate field statistics to the model in case some of its machinery needs it.

Parameters
fieldStats(dict) A dict of dicts with first key being the fieldname and the second key is min,max or other supported statistics

The documentation for this class was generated from the following file: