public class CLAClassifier
A CLA classifier accepts a binary input from the level below (the
"activationPattern") and information from the sensor and encoders (the
"classification") describing the input to the system at that time step.
When learning, for every bit in activation pattern, it records a history of the
classification each time that bit was active. The history is weighted so that
more recent activity has a bigger impact than older activity. The alpha
parameter controls this weighting.
For inference, it takes an ensemble approach. For every active bit in the
activationPattern, it looks up the most likely classification(s) from the
history stored for that bit and then votes across these to get the resulting
This classifier can learn and infer a number of simultaneous classifications
at once, each representing a shift of a different number of time steps. For
example, say you are doing multi-step prediction and want the predictions for
1 and 3 time steps in advance. The CLAClassifier would learn the associations
between the activation pattern for time step T and the classifications for
time step T+1, as well as the associations between activation pattern T and
the classifications for T+3. The 'steps' constructor argument specifies the
list of time-steps you want.
These are the bit histories. Each one is a BitHistory instance, stored in
this dict, where the key is (bit, nSteps). The 'bit' is the index of the
bit in the activation pattern and nSteps is the number of steps of
prediction desired for that bit.
This keeps track of the actual value to use for each bucket index. We
start with 1 bucket, no actual value so that the first infer has something
CLAClassifier no-arg constructor with defaults
public CLAClassifier(TIntList steps,
Constructor for the CLA classifier
steps - sequence of the different steps of multi-step predictions to learn
alpha - The alpha used to compute running averages of the bucket duty
cycles for each activation pattern bit. A lower alpha results
in longer term memory.
Process one input sample.
This method is called by outer loop code outside the nupic-engine. We
use this instead of the nupic engine compute() because our inputs and
outputs aren't fixed size vectors of reals.
recordNum - Record number of this input pattern. Record numbers should
normally increase sequentially by 1 each time unless there
are missing records in the dataset. Knowing this information
insures that we don't get confused by missing records.
classification - Map of the classification information:
bucketIdx: index of the encoder bucket
actValue: actual value going into the encoder
patternNZ - list of the active indices from the output below
learn - if true, learn this sample
infer - if true, perform inference
dict containing inference results, there is one entry for each
step in steps, where the key is the number of steps, and
the value is an array containing the relative likelihood for
each bucketIdx starting from bucketIdx 0.
There is also an entry containing the average actual value to
use for each bucket. The key is 'actualValues'.
1 : [0.1, 0.3, 0.2, 0.7],
4 : [0.2, 0.4, 0.3, 0.5],
'actualValues': [1.5, 3,5, 5,5, 7.6],