def setParameter(self, name, index, value): """ Set the value of the parameter. @param name -- the name of the parameter to update, as defined by the Node Spec. @param value -- the value to which the parameter is to be set. """ if name == "trainRecords": # Ensure that the trainRecords can only be set to minimum of the ROWID in # the saved states if not (isinstance(value, float) or isinstance(value, int)): raise HTMPredictionModelInvalidArgument( "Invalid argument type \'%s\'. threshold " "must be a number." % (type(value))) if len(self._recordsCache ) > 0 and value < self._recordsCache[0].ROWID: raise HTMPredictionModelInvalidArgument( "Invalid value. autoDetectWaitRecord " "value must be valid record within output stream. Current minimum " " ROWID in output stream is %d." % (self._recordsCache[0].ROWID)) self.trainRecords = value # Remove any labels before the first cached record (wont be used anymore) self._deleteRangeFromKNN(0, self._recordsCache[0].ROWID) # Reclassify all states self.classifyStates() elif name == "anomalyThreshold": if not (isinstance(value, float) or isinstance(value, int)): raise HTMPredictionModelInvalidArgument( "Invalid argument type \'%s\'. threshold " "must be a number." % (type(value))) self.anomalyThreshold = value self.classifyStates() elif name == "classificationMaxDist": if not (isinstance(value, float) or isinstance(value, int)): raise HTMPredictionModelInvalidArgument( "Invalid argument type \'%s\'. " "classificationMaxDist must be a number." % (type(value))) self._classificationMaxDist = value self.classifyStates() elif name == "activeColumnCount": self._activeColumnCount = value else: return PyRegion.setParameter(self, name, index, value)
def setAutoDetectWaitRecords(self, waitRecords): """ Sets the autoDetectWaitRecords. """ if not isinstance(waitRecords, int): raise HTMPredictionModelInvalidArgument("Invalid argument type \'%s\'. WaitRecord " "must be a number." % (type(waitRecords))) if len(self.saved_states) > 0 and waitRecords < self.saved_states[0].ROWID: raise HTMPredictionModelInvalidArgument("Invalid value. autoDetectWaitRecord value " "must be valid record within output stream. Current minimum ROWID in " "output stream is %d." % (self.saved_states[0].ROWID)) self._autoDetectWaitRecords = waitRecords # Update all the states in the classifier's cache for state in self.saved_states: self._updateState(state)
def setAutoDetectThreshold(self, threshold): """ Sets the autoDetectThreshold. TODO: Ensure previously classified points outside of classifier are valid. """ if not (isinstance(threshold, float) or isinstance(threshold, int)): raise HTMPredictionModelInvalidArgument("Invalid argument type \'%s\'. threshold " "must be a number." % (type(threshold))) self._autoDetectThreshold = threshold # Update all the states in the classifier's cache for state in self.saved_states: self._updateState(state)