class nupic::algorithms::sdr_classifier::SDRClassifier

Inherits from nupic::Serializable< SdrClassifierProto >

Public Functions


Constructor for use when deserializing.

SDRClassifier(const vector<UInt> &steps, Real64 alpha, Real64 actValueAlpha, UInt verbosity)


  • steps: The different number of steps to learn and predict.
  • alpha: The alpha to use when decaying the duty cycles.
  • actValueAlpha: The alpha to use when decaying the actual values for each bucket.
  • verbosity: The logging verbosity.

virtual ~SDRClassifier()


virtual void compute(UInt recordNum, const vector<UInt> &patternNZ, const vector<UInt> &bucketIdxList, const vector<Real64> &actValueList, bool category, bool learn, bool infer, ClassifierResult *result)

Compute the likelihoods for each bucket.

  • recordNum: An incrementing integer for each record. Gaps in numbers correspond to missing records.
  • patternNZ: The active input bit indices.
  • bucketIdx: The current value bucket index.
  • actValue: The current scalar value.
  • category: Whether the actual values represent categories.
  • learn: Whether or not to perform learning.
  • infer: Whether or not to perform inference.
  • result: A mapping from prediction step to a vector of likelihoods where the value at an index corresponds to the bucket with the same index. In addition, the values for key 0 correspond to the actual values to used when predicting each bucket.

UInt version() const

Gets the version number.

UInt getVerbosity() const

Getter and setter for verbosity level.

UInt getAlpha() const

Gets the learning rate.

UInt persistentSize() const

Get the size of the string needed for the serialized state.

void save(std::ostream &outStream) const

Save the state to the ostream.

void load(std::istream &inStream)

Load state from istream.

void write(SdrClassifierProto::Builder &proto) const

Save the state to the builder.

void read(SdrClassifierProto::Reader &proto)

Load state from reader.

virtual bool operator==(const SDRClassifier &other) const

Compare the other instance to this one.

true iff other is identical to this instance.
  • other: Another instance of SDRClassifier to compare to.


class nupic::algorithms::cla_classifier::ClassifierResult

CLA classifier result class.

Responsibility The ClassifierResult is responsible for storing result data and cleaning up the data when deleted.

Public Functions



virtual ~ClassifierResult()

Destructor - frees memory allocated during lifespan.

virtual vector<Real64> *createVector(Int step, UInt size, Real64 value)

Creates and returns a vector for a given step.

The vectors created are stored and can be accessed with the iterator methods. The vectors are owned by this class and are deleted in the destructor.

The specified vector.
  • step: The prediction step to create a vector for. If -1, then a vector for the actual values to use for each bucket is returned.
  • size: The size of the desired vector.
  • value: The value to populate the vector with.

virtual bool operator==(const ClassifierResult &other) const

Checks if the other instance has the exact same values.

True iff the other instance has the same values.
  • other: The other instance to compare to.

virtual map<Int, vector<Real64> *>::const_iterator begin()

Iterator method begin.

virtual map<Int, vector<Real64> *>::const_iterator end()

Iterator method end.