本文整理汇总了Python中KNNClassifierRegion.KNNClassifierRegion.setParameter方法的典型用法代码示例。如果您正苦于以下问题:Python KNNClassifierRegion.setParameter方法的具体用法?Python KNNClassifierRegion.setParameter怎么用?Python KNNClassifierRegion.setParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KNNClassifierRegion.KNNClassifierRegion
的用法示例。
在下文中一共展示了KNNClassifierRegion.setParameter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: KNNAnomalyClassifierRegion
# 需要导入模块: from KNNClassifierRegion import KNNClassifierRegion [as 别名]
# 或者: from KNNClassifierRegion.KNNClassifierRegion import setParameter [as 别名]
#.........这里部分代码省略.........
self.saved_categories = []
self._recordsCache = []
self._version = KNNAnomalyClassifierRegion.__VERSION__
# anomaly
self._anomaly = Anomaly()
def initialize(self, dims, splitterMaps):
assert tuple(dims) == (1,) * len(dims)
def getParameter(self, name, index=-1):
"""
Get the value of the parameter.
@param name -- the name of the parameter to retrieve, as defined
by the Node Spec.
"""
if name == "trainRecords":
return self.trainRecords
elif name == "anomalyThreshold":
return self.anomalyThreshold
elif name == "activeColumnCount":
return self._activeColumnCount
elif name == "classificationMaxDist":
return self._classificationMaxDist
else:
# If any spec parameter name is the same as an attribute, this call
# will get it automatically, e.g. self.learningMode
return PyRegion.getParameter(self, name, index)
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 CLAModelInvalidArgument("Invalid argument type \'%s\'. threshold "
"must be a number." % (type(value)))
if len(self._recordsCache) > 0 and value < self._recordsCache[0].ROWID:
raise CLAModelInvalidArgument("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 CLAModelInvalidArgument("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)):