partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
MultiArgMax
Get tuple (actually a generator) of indices where the max value of array x occurs. Requires that x have a max() method, as x.max() (in the case of NumPy) is much faster than max(x). For a simpler, faster argmax when there is only a single maximum entry, or when knowing only the first index where the maximum occ...
src/nupic/math/stats.py
def MultiArgMax(x): """ Get tuple (actually a generator) of indices where the max value of array x occurs. Requires that x have a max() method, as x.max() (in the case of NumPy) is much faster than max(x). For a simpler, faster argmax when there is only a single maximum entry, or when knowing only the first...
def MultiArgMax(x): """ Get tuple (actually a generator) of indices where the max value of array x occurs. Requires that x have a max() method, as x.max() (in the case of NumPy) is much faster than max(x). For a simpler, faster argmax when there is only a single maximum entry, or when knowing only the first...
[ "Get", "tuple", "(", "actually", "a", "generator", ")", "of", "indices", "where", "the", "max", "value", "of", "array", "x", "occurs", ".", "Requires", "that", "x", "have", "a", "max", "()", "method", "as", "x", ".", "max", "()", "(", "in", "the", ...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/math/stats.py#L81-L94
[ "def", "MultiArgMax", "(", "x", ")", ":", "m", "=", "x", ".", "max", "(", ")", "return", "(", "i", "for", "i", ",", "v", "in", "enumerate", "(", "x", ")", "if", "v", "==", "m", ")" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Any
Tests much faster (30%) than bool(sum(bool(x) for x in sequence)). :returns: (bool) true if any element of the sequence satisfies True. :param sequence: Any sequence whose elements can be evaluated as booleans.
src/nupic/math/stats.py
def Any(sequence): """ Tests much faster (30%) than bool(sum(bool(x) for x in sequence)). :returns: (bool) true if any element of the sequence satisfies True. :param sequence: Any sequence whose elements can be evaluated as booleans. """ return bool(reduce(lambda x, y: x or y, sequence, False))
def Any(sequence): """ Tests much faster (30%) than bool(sum(bool(x) for x in sequence)). :returns: (bool) true if any element of the sequence satisfies True. :param sequence: Any sequence whose elements can be evaluated as booleans. """ return bool(reduce(lambda x, y: x or y, sequence, False))
[ "Tests", "much", "faster", "(", "30%", ")", "than", "bool", "(", "sum", "(", "bool", "(", "x", ")", "for", "x", "in", "sequence", "))", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/math/stats.py#L98-L106
[ "def", "Any", "(", "sequence", ")", ":", "return", "bool", "(", "reduce", "(", "lambda", "x", ",", "y", ":", "x", "or", "y", ",", "sequence", ",", "False", ")", ")" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
All
:param sequence: Any sequence whose elements can be evaluated as booleans. :returns: true if all elements of the sequence satisfy True and x.
src/nupic/math/stats.py
def All(sequence): """ :param sequence: Any sequence whose elements can be evaluated as booleans. :returns: true if all elements of the sequence satisfy True and x. """ return bool(reduce(lambda x, y: x and y, sequence, True))
def All(sequence): """ :param sequence: Any sequence whose elements can be evaluated as booleans. :returns: true if all elements of the sequence satisfy True and x. """ return bool(reduce(lambda x, y: x and y, sequence, True))
[ ":", "param", "sequence", ":", "Any", "sequence", "whose", "elements", "can", "be", "evaluated", "as", "booleans", ".", ":", "returns", ":", "true", "if", "all", "elements", "of", "the", "sequence", "satisfy", "True", "and", "x", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/math/stats.py#L110-L115
[ "def", "All", "(", "sequence", ")", ":", "return", "bool", "(", "reduce", "(", "lambda", "x", ",", "y", ":", "x", "and", "y", ",", "sequence", ",", "True", ")", ")" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
MultiIndicator
Returns an array of length size and type dtype that is everywhere 0, except in the indices listed in sequence pos. :param pos: A single integer or sequence of integers that specify the position of ones to be set. :param size: The total size of the array to be returned. :param dtype: The element typ...
src/nupic/math/stats.py
def MultiIndicator(pos, size, dtype): """ Returns an array of length size and type dtype that is everywhere 0, except in the indices listed in sequence pos. :param pos: A single integer or sequence of integers that specify the position of ones to be set. :param size: The total size of the array t...
def MultiIndicator(pos, size, dtype): """ Returns an array of length size and type dtype that is everywhere 0, except in the indices listed in sequence pos. :param pos: A single integer or sequence of integers that specify the position of ones to be set. :param size: The total size of the array t...
[ "Returns", "an", "array", "of", "length", "size", "and", "type", "dtype", "that", "is", "everywhere", "0", "except", "in", "the", "indices", "listed", "in", "sequence", "pos", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/math/stats.py#L136-L152
[ "def", "MultiIndicator", "(", "pos", ",", "size", ",", "dtype", ")", ":", "x", "=", "numpy", ".", "zeros", "(", "size", ",", "dtype", "=", "dtype", ")", "if", "hasattr", "(", "pos", ",", "'__iter__'", ")", ":", "for", "i", "in", "pos", ":", "x", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Distribution
Returns an array of length size and type dtype that is everywhere 0, except in the indices listed in sequence pos. The non-zero indices contain a normalized distribution based on the counts. :param pos: A single integer or sequence of integers that specify the position of ones to be set. :param ...
src/nupic/math/stats.py
def Distribution(pos, size, counts, dtype): """ Returns an array of length size and type dtype that is everywhere 0, except in the indices listed in sequence pos. The non-zero indices contain a normalized distribution based on the counts. :param pos: A single integer or sequence of integers that specify...
def Distribution(pos, size, counts, dtype): """ Returns an array of length size and type dtype that is everywhere 0, except in the indices listed in sequence pos. The non-zero indices contain a normalized distribution based on the counts. :param pos: A single integer or sequence of integers that specify...
[ "Returns", "an", "array", "of", "length", "size", "and", "type", "dtype", "that", "is", "everywhere", "0", "except", "in", "the", "indices", "listed", "in", "sequence", "pos", ".", "The", "non", "-", "zero", "indices", "contain", "a", "normalized", "distri...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/math/stats.py#L156-L183
[ "def", "Distribution", "(", "pos", ",", "size", ",", "counts", ",", "dtype", ")", ":", "x", "=", "numpy", ".", "zeros", "(", "size", ",", "dtype", "=", "dtype", ")", "if", "hasattr", "(", "pos", ",", "'__iter__'", ")", ":", "# calculate normalization c...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
ConditionalProbabilityTable2D.grow
Grows the histogram to have rows rows and cols columns. Must not have been initialized before, or already have the same number of columns. If rows is smaller than the current number of rows, does not shrink. Also updates the sizes of the row and column sums. :param rows: Integer number of rows....
src/nupic/math/stats.py
def grow(self, rows, cols): """ Grows the histogram to have rows rows and cols columns. Must not have been initialized before, or already have the same number of columns. If rows is smaller than the current number of rows, does not shrink. Also updates the sizes of the row and column sums. ...
def grow(self, rows, cols): """ Grows the histogram to have rows rows and cols columns. Must not have been initialized before, or already have the same number of columns. If rows is smaller than the current number of rows, does not shrink. Also updates the sizes of the row and column sums. ...
[ "Grows", "the", "histogram", "to", "have", "rows", "rows", "and", "cols", "columns", ".", "Must", "not", "have", "been", "initialized", "before", "or", "already", "have", "the", "same", "number", "of", "columns", ".", "If", "rows", "is", "smaller", "than",...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/math/stats.py#L227-L260
[ "def", "grow", "(", "self", ",", "rows", ",", "cols", ")", ":", "if", "not", "self", ".", "hist_", ":", "self", ".", "hist_", "=", "SparseMatrix", "(", "rows", ",", "cols", ")", "self", ".", "rowSums_", "=", "numpy", ".", "zeros", "(", "rows", ",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
ConditionalProbabilityTable2D.updateRow
Add distribution to row row. Distribution should be an array of probabilities or counts. :param row: Integer index of the row to add to. May be larger than the current number of rows, in which case the histogram grows. :param distribution: Array of length equal to the ...
src/nupic/math/stats.py
def updateRow(self, row, distribution): """ Add distribution to row row. Distribution should be an array of probabilities or counts. :param row: Integer index of the row to add to. May be larger than the current number of rows, in which case the histogram grows. ...
def updateRow(self, row, distribution): """ Add distribution to row row. Distribution should be an array of probabilities or counts. :param row: Integer index of the row to add to. May be larger than the current number of rows, in which case the histogram grows. ...
[ "Add", "distribution", "to", "row", "row", ".", "Distribution", "should", "be", "an", "array", "of", "probabilities", "or", "counts", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/math/stats.py#L262-L276
[ "def", "updateRow", "(", "self", ",", "row", ",", "distribution", ")", ":", "self", ".", "grow", "(", "row", "+", "1", ",", "len", "(", "distribution", ")", ")", "self", ".", "hist_", ".", "axby", "(", "row", ",", "1", ",", "1", ",", "distributio...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
ConditionalProbabilityTable2D.inferRowCompat
Equivalent to the category inference of zeta1.TopLevel. Computes the max_prod (maximum component of a component-wise multiply) between the rows of the histogram and the incoming distribution. May be slow if the result of clean_outcpd() is not valid. :param distribution: Array of length equal to the num...
src/nupic/math/stats.py
def inferRowCompat(self, distribution): """ Equivalent to the category inference of zeta1.TopLevel. Computes the max_prod (maximum component of a component-wise multiply) between the rows of the histogram and the incoming distribution. May be slow if the result of clean_outcpd() is not valid. :...
def inferRowCompat(self, distribution): """ Equivalent to the category inference of zeta1.TopLevel. Computes the max_prod (maximum component of a component-wise multiply) between the rows of the histogram and the incoming distribution. May be slow if the result of clean_outcpd() is not valid. :...
[ "Equivalent", "to", "the", "category", "inference", "of", "zeta1", ".", "TopLevel", ".", "Computes", "the", "max_prod", "(", "maximum", "component", "of", "a", "component", "-", "wise", "multiply", ")", "between", "the", "rows", "of", "the", "histogram", "an...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/math/stats.py#L313-L325
[ "def", "inferRowCompat", "(", "self", ",", "distribution", ")", ":", "if", "self", ".", "hack_", "is", "None", ":", "self", ".", "clean_outcpd", "(", ")", "return", "self", ".", "hack_", ".", "vecMaxProd", "(", "distribution", ")" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
ConditionalProbabilityTable2D.clean_outcpd
Hack to act like clean_outcpd on zeta1.TopLevelNode. Take the max element in each to column, set it to 1, and set all the other elements to 0. Only called by inferRowMaxProd() and only needed if an updateRow() has been called since the last clean_outcpd().
src/nupic/math/stats.py
def clean_outcpd(self): """Hack to act like clean_outcpd on zeta1.TopLevelNode. Take the max element in each to column, set it to 1, and set all the other elements to 0. Only called by inferRowMaxProd() and only needed if an updateRow() has been called since the last clean_outcpd(). """ m = ...
def clean_outcpd(self): """Hack to act like clean_outcpd on zeta1.TopLevelNode. Take the max element in each to column, set it to 1, and set all the other elements to 0. Only called by inferRowMaxProd() and only needed if an updateRow() has been called since the last clean_outcpd(). """ m = ...
[ "Hack", "to", "act", "like", "clean_outcpd", "on", "zeta1", ".", "TopLevelNode", ".", "Take", "the", "max", "element", "in", "each", "to", "column", "set", "it", "to", "1", "and", "set", "all", "the", "other", "elements", "to", "0", ".", "Only", "calle...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/math/stats.py#L327-L341
[ "def", "clean_outcpd", "(", "self", ")", ":", "m", "=", "self", ".", "hist_", ".", "toDense", "(", ")", "for", "j", "in", "xrange", "(", "m", ".", "shape", "[", "1", "]", ")", ":", "# For each column.", "cmax", "=", "m", "[", ":", ",", "j", "]"...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
importAndRunFunction
Run a named function specified by a filesystem path, module name and function name. Returns the value returned by the imported function. Use this when access is needed to code that has not been added to a package accessible from the ordinary Python path. Encapsulates the multiple lines usually needed to s...
src/nupic/algorithms/utils.py
def importAndRunFunction( path, moduleName, funcName, **keywords ): """ Run a named function specified by a filesystem path, module name and function name. Returns the value returned by the imported function. Use this when access is needed to code that has not been added to a package acc...
def importAndRunFunction( path, moduleName, funcName, **keywords ): """ Run a named function specified by a filesystem path, module name and function name. Returns the value returned by the imported function. Use this when access is needed to code that has not been added to a package acc...
[ "Run", "a", "named", "function", "specified", "by", "a", "filesystem", "path", "module", "name", "and", "function", "name", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/utils.py#L26-L71
[ "def", "importAndRunFunction", "(", "path", ",", "moduleName", ",", "funcName", ",", "*", "*", "keywords", ")", ":", "import", "sys", "originalPath", "=", "sys", ".", "path", "try", ":", "augmentedPath", "=", "[", "path", "]", "+", "sys", ".", "path", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
transferCoincidences
Gets the coincidence matrix from one element and sets it on another element (using locked handles, a la nupic.bindings.research.lockHandle). TODO: Generalize to more node types, parameter name pairs, etc. Does not work across processes.
src/nupic/algorithms/utils.py
def transferCoincidences(network, fromElementName, toElementName): """ Gets the coincidence matrix from one element and sets it on another element (using locked handles, a la nupic.bindings.research.lockHandle). TODO: Generalize to more node types, parameter name pairs, etc. Does not work across processes...
def transferCoincidences(network, fromElementName, toElementName): """ Gets the coincidence matrix from one element and sets it on another element (using locked handles, a la nupic.bindings.research.lockHandle). TODO: Generalize to more node types, parameter name pairs, etc. Does not work across processes...
[ "Gets", "the", "coincidence", "matrix", "from", "one", "element", "and", "sets", "it", "on", "another", "element", "(", "using", "locked", "handles", "a", "la", "nupic", ".", "bindings", ".", "research", ".", "lockHandle", ")", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/utils.py#L86-L103
[ "def", "transferCoincidences", "(", "network", ",", "fromElementName", ",", "toElementName", ")", ":", "coincidenceHandle", "=", "getLockedHandle", "(", "runtimeElement", "=", "network", ".", "getElement", "(", "fromElementName", ")", ",", "# TODO: Re-purpose for use wi...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
MovingAverage.compute
Routine for computing a moving average. @param slidingWindow a list of previous values to use in computation that will be modified and returned @param total the sum of the values in slidingWindow to be used in the calculation of the moving average @param newVal a new number compute the new ...
src/nupic/utils.py
def compute(slidingWindow, total, newVal, windowSize): """Routine for computing a moving average. @param slidingWindow a list of previous values to use in computation that will be modified and returned @param total the sum of the values in slidingWindow to be used in the calculation of the ...
def compute(slidingWindow, total, newVal, windowSize): """Routine for computing a moving average. @param slidingWindow a list of previous values to use in computation that will be modified and returned @param total the sum of the values in slidingWindow to be used in the calculation of the ...
[ "Routine", "for", "computing", "a", "moving", "average", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/utils.py#L64-L82
[ "def", "compute", "(", "slidingWindow", ",", "total", ",", "newVal", ",", "windowSize", ")", ":", "if", "len", "(", "slidingWindow", ")", "==", "windowSize", ":", "total", "-=", "slidingWindow", ".", "pop", "(", "0", ")", "slidingWindow", ".", "append", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
MovingAverage.next
Instance method wrapper around compute.
src/nupic/utils.py
def next(self, newValue): """Instance method wrapper around compute.""" newAverage, self.slidingWindow, self.total = self.compute( self.slidingWindow, self.total, newValue, self.windowSize) return newAverage
def next(self, newValue): """Instance method wrapper around compute.""" newAverage, self.slidingWindow, self.total = self.compute( self.slidingWindow, self.total, newValue, self.windowSize) return newAverage
[ "Instance", "method", "wrapper", "around", "compute", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/utils.py#L85-L89
[ "def", "next", "(", "self", ",", "newValue", ")", ":", "newAverage", ",", "self", ".", "slidingWindow", ",", "self", ".", "total", "=", "self", ".", "compute", "(", "self", ".", "slidingWindow", ",", "self", ".", "total", ",", "newValue", ",", "self", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
getModule
Factory method to return an appropriate :class:`MetricsIface` module. - ``rmse``: :class:`MetricRMSE` - ``nrmse``: :class:`MetricNRMSE` - ``aae``: :class:`MetricAAE` - ``acc``: :class:`MetricAccuracy` - ``avg_err``: :class:`MetricAveError` - ``trivial``: :class:`MetricTrivial` - ``two_gram``: :class:`M...
src/nupic/frameworks/opf/metrics.py
def getModule(metricSpec): """ Factory method to return an appropriate :class:`MetricsIface` module. - ``rmse``: :class:`MetricRMSE` - ``nrmse``: :class:`MetricNRMSE` - ``aae``: :class:`MetricAAE` - ``acc``: :class:`MetricAccuracy` - ``avg_err``: :class:`MetricAveError` - ``trivial``: :class:`MetricT...
def getModule(metricSpec): """ Factory method to return an appropriate :class:`MetricsIface` module. - ``rmse``: :class:`MetricRMSE` - ``nrmse``: :class:`MetricNRMSE` - ``aae``: :class:`MetricAAE` - ``acc``: :class:`MetricAccuracy` - ``avg_err``: :class:`MetricAveError` - ``trivial``: :class:`MetricT...
[ "Factory", "method", "to", "return", "an", "appropriate", ":", "class", ":", "MetricsIface", "module", ".", "-", "rmse", ":", ":", "class", ":", "MetricRMSE", "-", "nrmse", ":", ":", "class", ":", "MetricNRMSE", "-", "aae", ":", ":", "class", ":", "Met...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/metrics.py#L199-L272
[ "def", "getModule", "(", "metricSpec", ")", ":", "metricName", "=", "metricSpec", ".", "metric", "if", "metricName", "==", "'rmse'", ":", "return", "MetricRMSE", "(", "metricSpec", ")", "if", "metricName", "==", "'nrmse'", ":", "return", "MetricNRMSE", "(", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
MetricSpec.getLabel
Helper method that generates a unique label for a :class:`MetricSpec` / :class:`~nupic.frameworks.opf.opf_utils.InferenceType` pair. The label is formatted as follows: :: <predictionKind>:<metric type>:(paramName=value)*:field=<fieldname> For example: :: class...
src/nupic/frameworks/opf/metrics.py
def getLabel(self, inferenceType=None): """ Helper method that generates a unique label for a :class:`MetricSpec` / :class:`~nupic.frameworks.opf.opf_utils.InferenceType` pair. The label is formatted as follows: :: <predictionKind>:<metric type>:(paramName=value)*:field=<fieldna...
def getLabel(self, inferenceType=None): """ Helper method that generates a unique label for a :class:`MetricSpec` / :class:`~nupic.frameworks.opf.opf_utils.InferenceType` pair. The label is formatted as follows: :: <predictionKind>:<metric type>:(paramName=value)*:field=<fieldna...
[ "Helper", "method", "that", "generates", "a", "unique", "label", "for", "a", ":", "class", ":", "MetricSpec", "/", ":", "class", ":", "~nupic", ".", "frameworks", ".", "opf", ".", "opf_utils", ".", "InferenceType", "pair", ".", "The", "label", "is", "for...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/metrics.py#L135-L177
[ "def", "getLabel", "(", "self", ",", "inferenceType", "=", "None", ")", ":", "result", "=", "[", "]", "if", "inferenceType", "is", "not", "None", ":", "result", ".", "append", "(", "InferenceType", ".", "getLabel", "(", "inferenceType", ")", ")", "result...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
MetricSpec.getInferenceTypeFromLabel
Extracts the PredictionKind (temporal vs. nontemporal) from the given metric label. :param label: (string) for a metric spec generated by :meth:`getMetricLabel` :returns: (:class:`~nupic.frameworks.opf.opf_utils.InferenceType`)
src/nupic/frameworks/opf/metrics.py
def getInferenceTypeFromLabel(cls, label): """ Extracts the PredictionKind (temporal vs. nontemporal) from the given metric label. :param label: (string) for a metric spec generated by :meth:`getMetricLabel` :returns: (:class:`~nupic.frameworks.opf.opf_utils.InferenceType`) """ ...
def getInferenceTypeFromLabel(cls, label): """ Extracts the PredictionKind (temporal vs. nontemporal) from the given metric label. :param label: (string) for a metric spec generated by :meth:`getMetricLabel` :returns: (:class:`~nupic.frameworks.opf.opf_utils.InferenceType`) """ ...
[ "Extracts", "the", "PredictionKind", "(", "temporal", "vs", ".", "nontemporal", ")", "from", "the", "given", "metric", "label", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/metrics.py#L180-L195
[ "def", "getInferenceTypeFromLabel", "(", "cls", ",", "label", ")", ":", "infType", ",", "_", ",", "_", "=", "label", ".", "partition", "(", "cls", ".", "_LABEL_SEPARATOR", ")", "if", "not", "InferenceType", ".", "validate", "(", "infType", ")", ":", "ret...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
AggregateMetric._getShiftedGroundTruth
Utility function that saves the passed in groundTruth into a local history buffer, and returns the groundTruth from self._predictionSteps ago, where self._predictionSteps is defined by the 'steps' parameter. This can be called from the beginning of a derived class's addInstance() before it passes ground...
src/nupic/frameworks/opf/metrics.py
def _getShiftedGroundTruth(self, groundTruth): """ Utility function that saves the passed in groundTruth into a local history buffer, and returns the groundTruth from self._predictionSteps ago, where self._predictionSteps is defined by the 'steps' parameter. This can be called from the beginning of a de...
def _getShiftedGroundTruth(self, groundTruth): """ Utility function that saves the passed in groundTruth into a local history buffer, and returns the groundTruth from self._predictionSteps ago, where self._predictionSteps is defined by the 'steps' parameter. This can be called from the beginning of a de...
[ "Utility", "function", "that", "saves", "the", "passed", "in", "groundTruth", "into", "a", "local", "history", "buffer", "and", "returns", "the", "groundTruth", "from", "self", ".", "_predictionSteps", "ago", "where", "self", ".", "_predictionSteps", "is", "defi...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/metrics.py#L509-L529
[ "def", "_getShiftedGroundTruth", "(", "self", ",", "groundTruth", ")", ":", "# Save this ground truth into our input history", "self", ".", "_groundTruthHistory", ".", "append", "(", "groundTruth", ")", "# This is only supported when _predictionSteps has one item in it", "assert"...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
MetricPassThruPrediction.addInstance
Compute and store metric value
src/nupic/frameworks/opf/metrics.py
def addInstance(self, groundTruth, prediction, record = None, result = None): """Compute and store metric value""" self.value = self.avg(prediction)
def addInstance(self, groundTruth, prediction, record = None, result = None): """Compute and store metric value""" self.value = self.avg(prediction)
[ "Compute", "and", "store", "metric", "value" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/metrics.py#L829-L831
[ "def", "addInstance", "(", "self", ",", "groundTruth", ",", "prediction", ",", "record", "=", "None", ",", "result", "=", "None", ")", ":", "self", ".", "value", "=", "self", ".", "avg", "(", "prediction", ")" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
CustomErrorMetric.mostLikely
Helper function to return a scalar value representing the most likely outcome given a probability distribution
src/nupic/frameworks/opf/metrics.py
def mostLikely(self, pred): """ Helper function to return a scalar value representing the most likely outcome given a probability distribution """ if len(pred) == 1: return pred.keys()[0] mostLikelyOutcome = None maxProbability = 0 for prediction, probability in pred.items(): ...
def mostLikely(self, pred): """ Helper function to return a scalar value representing the most likely outcome given a probability distribution """ if len(pred) == 1: return pred.keys()[0] mostLikelyOutcome = None maxProbability = 0 for prediction, probability in pred.items(): ...
[ "Helper", "function", "to", "return", "a", "scalar", "value", "representing", "the", "most", "likely", "outcome", "given", "a", "probability", "distribution" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/metrics.py#L1014-L1029
[ "def", "mostLikely", "(", "self", ",", "pred", ")", ":", "if", "len", "(", "pred", ")", "==", "1", ":", "return", "pred", ".", "keys", "(", ")", "[", "0", "]", "mostLikelyOutcome", "=", "None", "maxProbability", "=", "0", "for", "prediction", ",", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
CustomErrorMetric.expValue
Helper function to return a scalar value representing the expected value of a probability distribution
src/nupic/frameworks/opf/metrics.py
def expValue(self, pred): """ Helper function to return a scalar value representing the expected value of a probability distribution """ if len(pred) == 1: return pred.keys()[0] return sum([x*p for x,p in pred.items()])
def expValue(self, pred): """ Helper function to return a scalar value representing the expected value of a probability distribution """ if len(pred) == 1: return pred.keys()[0] return sum([x*p for x,p in pred.items()])
[ "Helper", "function", "to", "return", "a", "scalar", "value", "representing", "the", "expected", "value", "of", "a", "probability", "distribution" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/metrics.py#L1031-L1038
[ "def", "expValue", "(", "self", ",", "pred", ")", ":", "if", "len", "(", "pred", ")", "==", "1", ":", "return", "pred", ".", "keys", "(", ")", "[", "0", "]", "return", "sum", "(", "[", "x", "*", "p", "for", "x", ",", "p", "in", "pred", ".",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Encoder.encode
Convenience wrapper for :meth:`.encodeIntoArray`. This may be less efficient because it allocates a new numpy array every call. :param inputData: input data to be encoded :return: a numpy array with the encoded representation of inputData
src/nupic/encoders/base.py
def encode(self, inputData): """Convenience wrapper for :meth:`.encodeIntoArray`. This may be less efficient because it allocates a new numpy array every call. :param inputData: input data to be encoded :return: a numpy array with the encoded representation of inputData """ output = numpy....
def encode(self, inputData): """Convenience wrapper for :meth:`.encodeIntoArray`. This may be less efficient because it allocates a new numpy array every call. :param inputData: input data to be encoded :return: a numpy array with the encoded representation of inputData """ output = numpy....
[ "Convenience", "wrapper", "for", ":", "meth", ":", ".", "encodeIntoArray", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/base.py#L140-L151
[ "def", "encode", "(", "self", ",", "inputData", ")", ":", "output", "=", "numpy", ".", "zeros", "(", "(", "self", ".", "getWidth", "(", ")", ",", ")", ",", "dtype", "=", "defaultDtype", ")", "self", ".", "encodeIntoArray", "(", "inputData", ",", "out...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Encoder.getScalarNames
Return the field names for each of the scalar values returned by getScalars. :param parentFieldName: The name of the encoder which is our parent. This name is prefixed to each of the field names within this encoder to form the keys of the dict() in the retval. :return: array of field names
src/nupic/encoders/base.py
def getScalarNames(self, parentFieldName=''): """ Return the field names for each of the scalar values returned by getScalars. :param parentFieldName: The name of the encoder which is our parent. This name is prefixed to each of the field names within this encoder to form the keys of th...
def getScalarNames(self, parentFieldName=''): """ Return the field names for each of the scalar values returned by getScalars. :param parentFieldName: The name of the encoder which is our parent. This name is prefixed to each of the field names within this encoder to form the keys of th...
[ "Return", "the", "field", "names", "for", "each", "of", "the", "scalar", "values", "returned", "by", "getScalars", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/base.py#L154-L179
[ "def", "getScalarNames", "(", "self", ",", "parentFieldName", "=", "''", ")", ":", "names", "=", "[", "]", "if", "self", ".", "encoders", "is", "not", "None", ":", "for", "(", "name", ",", "encoder", ",", "offset", ")", "in", "self", ".", "encoders",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Encoder.getDecoderOutputFieldTypes
Returns a sequence of field types corresponding to the elements in the decoded output field array. The types are defined by :class:`~nupic.data.field_meta.FieldMetaType`. :return: list of :class:`~nupic.data.field_meta.FieldMetaType` objects
src/nupic/encoders/base.py
def getDecoderOutputFieldTypes(self): """ Returns a sequence of field types corresponding to the elements in the decoded output field array. The types are defined by :class:`~nupic.data.field_meta.FieldMetaType`. :return: list of :class:`~nupic.data.field_meta.FieldMetaType` objects """ if...
def getDecoderOutputFieldTypes(self): """ Returns a sequence of field types corresponding to the elements in the decoded output field array. The types are defined by :class:`~nupic.data.field_meta.FieldMetaType`. :return: list of :class:`~nupic.data.field_meta.FieldMetaType` objects """ if...
[ "Returns", "a", "sequence", "of", "field", "types", "corresponding", "to", "the", "elements", "in", "the", "decoded", "output", "field", "array", ".", "The", "types", "are", "defined", "by", ":", "class", ":", "~nupic", ".", "data", ".", "field_meta", ".",...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/base.py#L182-L204
[ "def", "getDecoderOutputFieldTypes", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'_flattenedFieldTypeList'", ")", "and", "self", ".", "_flattenedFieldTypeList", "is", "not", "None", ":", "return", "self", ".", "_flattenedFieldTypeList", "fieldTypes", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Encoder._getInputValue
Gets the value of a given field from the input record
src/nupic/encoders/base.py
def _getInputValue(self, obj, fieldName): """ Gets the value of a given field from the input record """ if isinstance(obj, dict): if not fieldName in obj: knownFields = ", ".join( key for key in obj.keys() if not key.startswith("_") ) raise ValueError( "...
def _getInputValue(self, obj, fieldName): """ Gets the value of a given field from the input record """ if isinstance(obj, dict): if not fieldName in obj: knownFields = ", ".join( key for key in obj.keys() if not key.startswith("_") ) raise ValueError( "...
[ "Gets", "the", "value", "of", "a", "given", "field", "from", "the", "input", "record" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/base.py#L216-L234
[ "def", "_getInputValue", "(", "self", ",", "obj", ",", "fieldName", ")", ":", "if", "isinstance", "(", "obj", ",", "dict", ")", ":", "if", "not", "fieldName", "in", "obj", ":", "knownFields", "=", "\", \"", ".", "join", "(", "key", "for", "key", "in"...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Encoder.getEncoderList
:return: a reference to each sub-encoder in this encoder. They are returned in the same order as they are for :meth:`.getScalarNames` and :meth:`.getScalars`.
src/nupic/encoders/base.py
def getEncoderList(self): """ :return: a reference to each sub-encoder in this encoder. They are returned in the same order as they are for :meth:`.getScalarNames` and :meth:`.getScalars`. """ if hasattr(self, '_flattenedEncoderList') and \ self._flattenedEncoderList i...
def getEncoderList(self): """ :return: a reference to each sub-encoder in this encoder. They are returned in the same order as they are for :meth:`.getScalarNames` and :meth:`.getScalars`. """ if hasattr(self, '_flattenedEncoderList') and \ self._flattenedEncoderList i...
[ ":", "return", ":", "a", "reference", "to", "each", "sub", "-", "encoder", "in", "this", "encoder", ".", "They", "are", "returned", "in", "the", "same", "order", "as", "they", "are", "for", ":", "meth", ":", ".", "getScalarNames", "and", ":", "meth", ...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/base.py#L237-L259
[ "def", "getEncoderList", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'_flattenedEncoderList'", ")", "and", "self", ".", "_flattenedEncoderList", "is", "not", "None", ":", "return", "self", ".", "_flattenedEncoderList", "encoders", "=", "[", "]",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Encoder.getScalars
Returns a numpy array containing the sub-field scalar value(s) for each sub-field of the ``inputData``. To get the associated field names for each of the scalar values, call :meth:`.getScalarNames()`. For a simple scalar encoder, the scalar value is simply the input unmodified. For category encoders, i...
src/nupic/encoders/base.py
def getScalars(self, inputData): """ Returns a numpy array containing the sub-field scalar value(s) for each sub-field of the ``inputData``. To get the associated field names for each of the scalar values, call :meth:`.getScalarNames()`. For a simple scalar encoder, the scalar value is simply the i...
def getScalars(self, inputData): """ Returns a numpy array containing the sub-field scalar value(s) for each sub-field of the ``inputData``. To get the associated field names for each of the scalar values, call :meth:`.getScalarNames()`. For a simple scalar encoder, the scalar value is simply the i...
[ "Returns", "a", "numpy", "array", "containing", "the", "sub", "-", "field", "scalar", "value", "(", "s", ")", "for", "each", "sub", "-", "field", "of", "the", "inputData", ".", "To", "get", "the", "associated", "field", "names", "for", "each", "of", "t...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/base.py#L262-L292
[ "def", "getScalars", "(", "self", ",", "inputData", ")", ":", "retVals", "=", "numpy", ".", "array", "(", "[", "]", ")", "if", "self", ".", "encoders", "is", "not", "None", ":", "for", "(", "name", ",", "encoder", ",", "offset", ")", "in", "self", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Encoder.getEncodedValues
Returns the input in the same format as is returned by :meth:`.topDownCompute`. For most encoder types, this is the same as the input data. For instance, for scalar and category types, this corresponds to the numeric and string values, respectively, from the inputs. For datetime encoders, this returns t...
src/nupic/encoders/base.py
def getEncodedValues(self, inputData): """ Returns the input in the same format as is returned by :meth:`.topDownCompute`. For most encoder types, this is the same as the input data. For instance, for scalar and category types, this corresponds to the numeric and string values, respectively, from th...
def getEncodedValues(self, inputData): """ Returns the input in the same format as is returned by :meth:`.topDownCompute`. For most encoder types, this is the same as the input data. For instance, for scalar and category types, this corresponds to the numeric and string values, respectively, from th...
[ "Returns", "the", "input", "in", "the", "same", "format", "as", "is", "returned", "by", ":", "meth", ":", ".", "topDownCompute", ".", "For", "most", "encoder", "types", "this", "is", "the", "same", "as", "the", "input", "data", ".", "For", "instance", ...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/base.py#L295-L330
[ "def", "getEncodedValues", "(", "self", ",", "inputData", ")", ":", "retVals", "=", "[", "]", "if", "self", ".", "encoders", "is", "not", "None", ":", "for", "name", ",", "encoders", ",", "offset", "in", "self", ".", "encoders", ":", "values", "=", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Encoder.getBucketIndices
Returns an array containing the sub-field bucket indices for each sub-field of the inputData. To get the associated field names for each of the buckets, call :meth:`.getScalarNames`. :param inputData: The data from the source. This is typically an object with members. :return: array of...
src/nupic/encoders/base.py
def getBucketIndices(self, inputData): """ Returns an array containing the sub-field bucket indices for each sub-field of the inputData. To get the associated field names for each of the buckets, call :meth:`.getScalarNames`. :param inputData: The data from the source. This is typically an object w...
def getBucketIndices(self, inputData): """ Returns an array containing the sub-field bucket indices for each sub-field of the inputData. To get the associated field names for each of the buckets, call :meth:`.getScalarNames`. :param inputData: The data from the source. This is typically an object w...
[ "Returns", "an", "array", "containing", "the", "sub", "-", "field", "bucket", "indices", "for", "each", "sub", "-", "field", "of", "the", "inputData", ".", "To", "get", "the", "associated", "field", "names", "for", "each", "of", "the", "buckets", "call", ...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/base.py#L333-L354
[ "def", "getBucketIndices", "(", "self", ",", "inputData", ")", ":", "retVals", "=", "[", "]", "if", "self", ".", "encoders", "is", "not", "None", ":", "for", "(", "name", ",", "encoder", ",", "offset", ")", "in", "self", ".", "encoders", ":", "values...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Encoder.scalarsToStr
Return a pretty print string representing the return values from :meth:`.getScalars` and :meth:`.getScalarNames`. :param scalarValues: input values to encode to string :param scalarNames: optional input of scalar names to convert. If None, gets scalar names from :meth:`.getScalarName...
src/nupic/encoders/base.py
def scalarsToStr(self, scalarValues, scalarNames=None): """ Return a pretty print string representing the return values from :meth:`.getScalars` and :meth:`.getScalarNames`. :param scalarValues: input values to encode to string :param scalarNames: optional input of scalar names to convert. If None,...
def scalarsToStr(self, scalarValues, scalarNames=None): """ Return a pretty print string representing the return values from :meth:`.getScalars` and :meth:`.getScalarNames`. :param scalarValues: input values to encode to string :param scalarNames: optional input of scalar names to convert. If None,...
[ "Return", "a", "pretty", "print", "string", "representing", "the", "return", "values", "from", ":", "meth", ":", ".", "getScalars", "and", ":", "meth", ":", ".", "getScalarNames", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/base.py#L357-L378
[ "def", "scalarsToStr", "(", "self", ",", "scalarValues", ",", "scalarNames", "=", "None", ")", ":", "if", "scalarNames", "is", "None", ":", "scalarNames", "=", "self", ".", "getScalarNames", "(", ")", "desc", "=", "''", "for", "(", "name", ",", "value", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Encoder.getFieldDescription
Return the offset and length of a given field within the encoded output. :param fieldName: Name of the field :return: tuple(``offset``, ``width``) of the field within the encoded output
src/nupic/encoders/base.py
def getFieldDescription(self, fieldName): """ Return the offset and length of a given field within the encoded output. :param fieldName: Name of the field :return: tuple(``offset``, ``width``) of the field within the encoded output """ # Find which field it's in description = self.getDescr...
def getFieldDescription(self, fieldName): """ Return the offset and length of a given field within the encoded output. :param fieldName: Name of the field :return: tuple(``offset``, ``width``) of the field within the encoded output """ # Find which field it's in description = self.getDescr...
[ "Return", "the", "offset", "and", "length", "of", "a", "given", "field", "within", "the", "encoded", "output", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/base.py#L397-L416
[ "def", "getFieldDescription", "(", "self", ",", "fieldName", ")", ":", "# Find which field it's in", "description", "=", "self", ".", "getDescription", "(", ")", "+", "[", "(", "\"end\"", ",", "self", ".", "getWidth", "(", ")", ")", "]", "for", "i", "in", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Encoder.encodedBitDescription
Return a description of the given bit in the encoded output. This will include the field name and the offset within the field. :param bitOffset: Offset of the bit to get the description of :param formatted: If True, the bitOffset is w.r.t. formatted output, which include...
src/nupic/encoders/base.py
def encodedBitDescription(self, bitOffset, formatted=False): """ Return a description of the given bit in the encoded output. This will include the field name and the offset within the field. :param bitOffset: Offset of the bit to get the description of :param formatted: If True, the bitO...
def encodedBitDescription(self, bitOffset, formatted=False): """ Return a description of the given bit in the encoded output. This will include the field name and the offset within the field. :param bitOffset: Offset of the bit to get the description of :param formatted: If True, the bitO...
[ "Return", "a", "description", "of", "the", "given", "bit", "in", "the", "encoded", "output", ".", "This", "will", "include", "the", "field", "name", "and", "the", "offset", "within", "the", "field", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/base.py#L419-L453
[ "def", "encodedBitDescription", "(", "self", ",", "bitOffset", ",", "formatted", "=", "False", ")", ":", "# Find which field it's in", "(", "prevFieldName", ",", "prevFieldOffset", ")", "=", "(", "None", ",", "None", ")", "description", "=", "self", ".", "getD...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Encoder.pprintHeader
Pretty-print a header that labels the sub-fields of the encoded output. This can be used in conjuction with :meth:`.pprint`. :param prefix: printed before the header if specified
src/nupic/encoders/base.py
def pprintHeader(self, prefix=""): """ Pretty-print a header that labels the sub-fields of the encoded output. This can be used in conjuction with :meth:`.pprint`. :param prefix: printed before the header if specified """ print prefix, description = self.getDescription() + [("end", self.get...
def pprintHeader(self, prefix=""): """ Pretty-print a header that labels the sub-fields of the encoded output. This can be used in conjuction with :meth:`.pprint`. :param prefix: printed before the header if specified """ print prefix, description = self.getDescription() + [("end", self.get...
[ "Pretty", "-", "print", "a", "header", "that", "labels", "the", "sub", "-", "fields", "of", "the", "encoded", "output", ".", "This", "can", "be", "used", "in", "conjuction", "with", ":", "meth", ":", ".", "pprint", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/base.py#L456-L475
[ "def", "pprintHeader", "(", "self", ",", "prefix", "=", "\"\"", ")", ":", "print", "prefix", ",", "description", "=", "self", ".", "getDescription", "(", ")", "+", "[", "(", "\"end\"", ",", "self", ".", "getWidth", "(", ")", ")", "]", "for", "i", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Encoder.pprint
Pretty-print the encoded output using ascii art. :param output: to print :param prefix: printed before the header if specified
src/nupic/encoders/base.py
def pprint(self, output, prefix=""): """ Pretty-print the encoded output using ascii art. :param output: to print :param prefix: printed before the header if specified """ print prefix, description = self.getDescription() + [("end", self.getWidth())] for i in xrange(len(description) - 1...
def pprint(self, output, prefix=""): """ Pretty-print the encoded output using ascii art. :param output: to print :param prefix: printed before the header if specified """ print prefix, description = self.getDescription() + [("end", self.getWidth())] for i in xrange(len(description) - 1...
[ "Pretty", "-", "print", "the", "encoded", "output", "using", "ascii", "art", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/base.py#L478-L491
[ "def", "pprint", "(", "self", ",", "output", ",", "prefix", "=", "\"\"", ")", ":", "print", "prefix", ",", "description", "=", "self", ".", "getDescription", "(", ")", "+", "[", "(", "\"end\"", ",", "self", ".", "getWidth", "(", ")", ")", "]", "for...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Encoder.decode
Takes an encoded output and does its best to work backwards and generate the input that would have generated it. In cases where the encoded output contains more ON bits than an input would have generated, this routine will return one or more ranges of inputs which, if their encoded outputs were ORed to...
src/nupic/encoders/base.py
def decode(self, encoded, parentFieldName=''): """ Takes an encoded output and does its best to work backwards and generate the input that would have generated it. In cases where the encoded output contains more ON bits than an input would have generated, this routine will return one or more ranges...
def decode(self, encoded, parentFieldName=''): """ Takes an encoded output and does its best to work backwards and generate the input that would have generated it. In cases where the encoded output contains more ON bits than an input would have generated, this routine will return one or more ranges...
[ "Takes", "an", "encoded", "output", "and", "does", "its", "best", "to", "work", "backwards", "and", "generate", "the", "input", "that", "would", "have", "generated", "it", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/base.py#L494-L590
[ "def", "decode", "(", "self", ",", "encoded", ",", "parentFieldName", "=", "''", ")", ":", "fieldsDict", "=", "dict", "(", ")", "fieldsOrder", "=", "[", "]", "# What is the effective parent name?", "if", "parentFieldName", "==", "''", ":", "parentName", "=", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Encoder.decodedToStr
Return a pretty print string representing the return value from :meth:`.decode`.
src/nupic/encoders/base.py
def decodedToStr(self, decodeResults): """ Return a pretty print string representing the return value from :meth:`.decode`. """ (fieldsDict, fieldsOrder) = decodeResults desc = '' for fieldName in fieldsOrder: (ranges, rangesStr) = fieldsDict[fieldName] if len(desc) > 0: ...
def decodedToStr(self, decodeResults): """ Return a pretty print string representing the return value from :meth:`.decode`. """ (fieldsDict, fieldsOrder) = decodeResults desc = '' for fieldName in fieldsOrder: (ranges, rangesStr) = fieldsDict[fieldName] if len(desc) > 0: ...
[ "Return", "a", "pretty", "print", "string", "representing", "the", "return", "value", "from", ":", "meth", ":", ".", "decode", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/base.py#L593-L611
[ "def", "decodedToStr", "(", "self", ",", "decodeResults", ")", ":", "(", "fieldsDict", ",", "fieldsOrder", ")", "=", "decodeResults", "desc", "=", "''", "for", "fieldName", "in", "fieldsOrder", ":", "(", "ranges", ",", "rangesStr", ")", "=", "fieldsDict", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Encoder.getBucketInfo
Returns a list of :class:`.EncoderResult` namedtuples describing the inputs for each sub-field that correspond to the bucket indices passed in ``buckets``. To get the associated field names for each of the values, call :meth:`.getScalarNames`. :param buckets: The list of bucket indices, one for each su...
src/nupic/encoders/base.py
def getBucketInfo(self, buckets): """ Returns a list of :class:`.EncoderResult` namedtuples describing the inputs for each sub-field that correspond to the bucket indices passed in ``buckets``. To get the associated field names for each of the values, call :meth:`.getScalarNames`. :param bucket...
def getBucketInfo(self, buckets): """ Returns a list of :class:`.EncoderResult` namedtuples describing the inputs for each sub-field that correspond to the bucket indices passed in ``buckets``. To get the associated field names for each of the values, call :meth:`.getScalarNames`. :param bucket...
[ "Returns", "a", "list", "of", ":", "class", ":", ".", "EncoderResult", "namedtuples", "describing", "the", "inputs", "for", "each", "sub", "-", "field", "that", "correspond", "to", "the", "bucket", "indices", "passed", "in", "buckets", ".", "To", "get", "t...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/base.py#L633-L666
[ "def", "getBucketInfo", "(", "self", ",", "buckets", ")", ":", "# Fall back topdown compute", "if", "self", ".", "encoders", "is", "None", ":", "raise", "RuntimeError", "(", "\"Must be implemented in sub-class\"", ")", "# Concatenate the results from bucketInfo on each chil...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Encoder.topDownCompute
Returns a list of :class:`.EncoderResult` namedtuples describing the top-down best guess inputs for each sub-field given the encoded output. These are the values which are most likely to generate the given encoded output. To get the associated field names for each of the values, call :meth:`.getScalarNa...
src/nupic/encoders/base.py
def topDownCompute(self, encoded): """ Returns a list of :class:`.EncoderResult` namedtuples describing the top-down best guess inputs for each sub-field given the encoded output. These are the values which are most likely to generate the given encoded output. To get the associated field names for e...
def topDownCompute(self, encoded): """ Returns a list of :class:`.EncoderResult` namedtuples describing the top-down best guess inputs for each sub-field given the encoded output. These are the values which are most likely to generate the given encoded output. To get the associated field names for e...
[ "Returns", "a", "list", "of", ":", "class", ":", ".", "EncoderResult", "namedtuples", "describing", "the", "top", "-", "down", "best", "guess", "inputs", "for", "each", "sub", "-", "field", "given", "the", "encoded", "output", ".", "These", "are", "the", ...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/base.py#L669-L704
[ "def", "topDownCompute", "(", "self", ",", "encoded", ")", ":", "# Fallback topdown compute", "if", "self", ".", "encoders", "is", "None", ":", "raise", "RuntimeError", "(", "\"Must be implemented in sub-class\"", ")", "# Concatenate the results from topDownCompute on each ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Encoder.closenessScores
Compute closeness scores between the expected scalar value(s) and actual scalar value(s). The expected scalar values are typically those obtained from the :meth:`.getScalars` method. The actual scalar values are typically those returned from :meth:`.topDownCompute`. This method returns one closeness sc...
src/nupic/encoders/base.py
def closenessScores(self, expValues, actValues, fractional=True): """ Compute closeness scores between the expected scalar value(s) and actual scalar value(s). The expected scalar values are typically those obtained from the :meth:`.getScalars` method. The actual scalar values are typically those re...
def closenessScores(self, expValues, actValues, fractional=True): """ Compute closeness scores between the expected scalar value(s) and actual scalar value(s). The expected scalar values are typically those obtained from the :meth:`.getScalars` method. The actual scalar values are typically those re...
[ "Compute", "closeness", "scores", "between", "the", "expected", "scalar", "value", "(", "s", ")", "and", "actual", "scalar", "value", "(", "s", ")", ".", "The", "expected", "scalar", "values", "are", "typically", "those", "obtained", "from", "the", ":", "m...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/base.py#L707-L758
[ "def", "closenessScores", "(", "self", ",", "expValues", ",", "actValues", ",", "fractional", "=", "True", ")", ":", "# Fallback closenss is a percentage match", "if", "self", ".", "encoders", "is", "None", ":", "err", "=", "abs", "(", "expValues", "[", "0", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
ModelHandler.POST
/models/{name} schema: { "modelParams": dict containing model parameters "predictedFieldName": str } returns: {"success":name}
src/nupic/simple_server.py
def POST(self, name): """ /models/{name} schema: { "modelParams": dict containing model parameters "predictedFieldName": str } returns: {"success":name} """ global g_models data = json.loads(web.data()) modelParams = data["modelParams"] predictedFieldName =...
def POST(self, name): """ /models/{name} schema: { "modelParams": dict containing model parameters "predictedFieldName": str } returns: {"success":name} """ global g_models data = json.loads(web.data()) modelParams = data["modelParams"] predictedFieldName =...
[ "/", "models", "/", "{", "name", "}" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/simple_server.py#L71-L97
[ "def", "POST", "(", "self", ",", "name", ")", ":", "global", "g_models", "data", "=", "json", ".", "loads", "(", "web", ".", "data", "(", ")", ")", "modelParams", "=", "data", "[", "\"modelParams\"", "]", "predictedFieldName", "=", "data", "[", "\"pred...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
ModelRunner.POST
/models/{name}/run schema: { predictedFieldName: value timestamp: %m/%d/%y %H:%M } NOTE: predictedFieldName MUST be the same name specified when creating the model. returns: { "predictionNumber":<number of record>, "anomalyScore":anomalyScore }
src/nupic/simple_server.py
def POST(self, name): """ /models/{name}/run schema: { predictedFieldName: value timestamp: %m/%d/%y %H:%M } NOTE: predictedFieldName MUST be the same name specified when creating the model. returns: { "predictionNumber":<number of record>, ...
def POST(self, name): """ /models/{name}/run schema: { predictedFieldName: value timestamp: %m/%d/%y %H:%M } NOTE: predictedFieldName MUST be the same name specified when creating the model. returns: { "predictionNumber":<number of record>, ...
[ "/", "models", "/", "{", "name", "}", "/", "run" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/simple_server.py#L103-L135
[ "def", "POST", "(", "self", ",", "name", ")", ":", "global", "g_models", "data", "=", "json", ".", "loads", "(", "web", ".", "data", "(", ")", ")", "data", "[", "\"timestamp\"", "]", "=", "datetime", ".", "datetime", ".", "strptime", "(", "data", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
analyzeOverlaps
Mirror Image Visualization: Shows the encoding space juxtaposed against the coincidence space. The encoding space is the bottom-up sensory encoding and the coincidence space depicts the corresponding activation of coincidences in the SP. Hence, the mirror image visualization is a visual depiction of the mapping...
examples/opf/tools/MirrorImageViz/mirrorImageViz.py
def analyzeOverlaps(activeCoincsFile, encodingsFile, dataset): '''Mirror Image Visualization: Shows the encoding space juxtaposed against the coincidence space. The encoding space is the bottom-up sensory encoding and the coincidence space depicts the corresponding activation of coincidences in the SP. Hence, t...
def analyzeOverlaps(activeCoincsFile, encodingsFile, dataset): '''Mirror Image Visualization: Shows the encoding space juxtaposed against the coincidence space. The encoding space is the bottom-up sensory encoding and the coincidence space depicts the corresponding activation of coincidences in the SP. Hence, t...
[ "Mirror", "Image", "Visualization", ":", "Shows", "the", "encoding", "space", "juxtaposed", "against", "the", "coincidence", "space", ".", "The", "encoding", "space", "is", "the", "bottom", "-", "up", "sensory", "encoding", "and", "the", "coincidence", "space", ...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/opf/tools/MirrorImageViz/mirrorImageViz.py#L27-L114
[ "def", "analyzeOverlaps", "(", "activeCoincsFile", ",", "encodingsFile", ",", "dataset", ")", ":", "lines", "=", "activeCoincsFile", ".", "readlines", "(", ")", "inputs", "=", "encodingsFile", ".", "readlines", "(", ")", "w", "=", "len", "(", "inputs", "[", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
drawFile
The similarity of two patterns in the bit-encoding space is displayed alongside their similarity in the sp-coinc space.
examples/opf/tools/MirrorImageViz/mirrorImageViz.py
def drawFile(dataset, matrix, patterns, cells, w, fnum): '''The similarity of two patterns in the bit-encoding space is displayed alongside their similarity in the sp-coinc space.''' score=0 count = 0 assert len(patterns)==len(cells) for p in xrange(len(patterns)-1): matrix[p+1:,p] = [len(set(patterns[p...
def drawFile(dataset, matrix, patterns, cells, w, fnum): '''The similarity of two patterns in the bit-encoding space is displayed alongside their similarity in the sp-coinc space.''' score=0 count = 0 assert len(patterns)==len(cells) for p in xrange(len(patterns)-1): matrix[p+1:,p] = [len(set(patterns[p...
[ "The", "similarity", "of", "two", "patterns", "in", "the", "bit", "-", "encoding", "space", "is", "displayed", "alongside", "their", "similarity", "in", "the", "sp", "-", "coinc", "space", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/opf/tools/MirrorImageViz/mirrorImageViz.py#L116-L136
[ "def", "drawFile", "(", "dataset", ",", "matrix", ",", "patterns", ",", "cells", ",", "w", ",", "fnum", ")", ":", "score", "=", "0", "count", "=", "0", "assert", "len", "(", "patterns", ")", "==", "len", "(", "cells", ")", "for", "p", "in", "xran...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
printOverlaps
Compare the results and return True if success, False if failure Parameters: -------------------------------------------------------------------- coincs: Which cells are we comparing? comparedTo: The set of 40 cells we being compared to (they have no overlap with seen) seen: ...
examples/opf/tools/MirrorImageViz/mirrorImageViz.py
def printOverlaps(comparedTo, coincs, seen): """ Compare the results and return True if success, False if failure Parameters: -------------------------------------------------------------------- coincs: Which cells are we comparing? comparedTo: The set of 40 cells we being compare...
def printOverlaps(comparedTo, coincs, seen): """ Compare the results and return True if success, False if failure Parameters: -------------------------------------------------------------------- coincs: Which cells are we comparing? comparedTo: The set of 40 cells we being compare...
[ "Compare", "the", "results", "and", "return", "True", "if", "success", "False", "if", "failure", "Parameters", ":", "--------------------------------------------------------------------", "coincs", ":", "Which", "cells", "are", "we", "comparing?", "comparedTo", ":", "Th...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/opf/tools/MirrorImageViz/mirrorImageViz.py#L138-L166
[ "def", "printOverlaps", "(", "comparedTo", ",", "coincs", ",", "seen", ")", ":", "inputOverlap", "=", "0", "cellOverlap", "=", "0", "for", "y", "in", "comparedTo", ":", "closestInputs", "=", "[", "]", "closestCells", "=", "[", "]", "if", "len", "(", "s...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Example.createInput
create a random input vector
examples/sp/hello_sp.py
def createInput(self): """create a random input vector""" print "-" * 70 + "Creating a random input vector" + "-" * 70 #clear the inputArray to zero before creating a new input vector self.inputArray[0:] = 0 for i in range(self.inputSize): #randrange returns 0 or 1 self.inputArray[i] ...
def createInput(self): """create a random input vector""" print "-" * 70 + "Creating a random input vector" + "-" * 70 #clear the inputArray to zero before creating a new input vector self.inputArray[0:] = 0 for i in range(self.inputSize): #randrange returns 0 or 1 self.inputArray[i] ...
[ "create", "a", "random", "input", "vector" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/sp/hello_sp.py#L68-L78
[ "def", "createInput", "(", "self", ")", ":", "print", "\"-\"", "*", "70", "+", "\"Creating a random input vector\"", "+", "\"-\"", "*", "70", "#clear the inputArray to zero before creating a new input vector", "self", ".", "inputArray", "[", "0", ":", "]", "=", "0",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Example.run
Run the spatial pooler with the input vector
examples/sp/hello_sp.py
def run(self): """Run the spatial pooler with the input vector""" print "-" * 80 + "Computing the SDR" + "-" * 80 #activeArray[column]=1 if column is active after spatial pooling self.sp.compute(self.inputArray, True, self.activeArray) print self.activeArray.nonzero()
def run(self): """Run the spatial pooler with the input vector""" print "-" * 80 + "Computing the SDR" + "-" * 80 #activeArray[column]=1 if column is active after spatial pooling self.sp.compute(self.inputArray, True, self.activeArray) print self.activeArray.nonzero()
[ "Run", "the", "spatial", "pooler", "with", "the", "input", "vector" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/sp/hello_sp.py#L81-L89
[ "def", "run", "(", "self", ")", ":", "print", "\"-\"", "*", "80", "+", "\"Computing the SDR\"", "+", "\"-\"", "*", "80", "#activeArray[column]=1 if column is active after spatial pooling", "self", ".", "sp", ".", "compute", "(", "self", ".", "inputArray", ",", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Example.addNoise
Flip the value of 10% of input bits (add noise) :param noiseLevel: The percentage of total input bits that should be flipped
examples/sp/hello_sp.py
def addNoise(self, noiseLevel): """Flip the value of 10% of input bits (add noise) :param noiseLevel: The percentage of total input bits that should be flipped """ for _ in range(int(noiseLevel * self.inputSize)): # 0.1*self.inputSize represents 10% of the total input bits # random.random(...
def addNoise(self, noiseLevel): """Flip the value of 10% of input bits (add noise) :param noiseLevel: The percentage of total input bits that should be flipped """ for _ in range(int(noiseLevel * self.inputSize)): # 0.1*self.inputSize represents 10% of the total input bits # random.random(...
[ "Flip", "the", "value", "of", "10%", "of", "input", "bits", "(", "add", "noise", ")" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/sp/hello_sp.py#L92-L108
[ "def", "addNoise", "(", "self", ",", "noiseLevel", ")", ":", "for", "_", "in", "range", "(", "int", "(", "noiseLevel", "*", "self", ".", "inputSize", ")", ")", ":", "# 0.1*self.inputSize represents 10% of the total input bits", "# random.random() returns a float betwe...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
_labeledInput
Print the list of [column, cellIdx] indices for each of the active cells in activeInputs.
src/nupic/algorithms/knn_classifier.py
def _labeledInput(activeInputs, cellsPerCol=32): """Print the list of [column, cellIdx] indices for each of the active cells in activeInputs. """ if cellsPerCol == 0: cellsPerCol = 1 cols = activeInputs.size / cellsPerCol activeInputs = activeInputs.reshape(cols, cellsPerCol) (cols, cellIdxs) = active...
def _labeledInput(activeInputs, cellsPerCol=32): """Print the list of [column, cellIdx] indices for each of the active cells in activeInputs. """ if cellsPerCol == 0: cellsPerCol = 1 cols = activeInputs.size / cellsPerCol activeInputs = activeInputs.reshape(cols, cellsPerCol) (cols, cellIdxs) = active...
[ "Print", "the", "list", "of", "[", "column", "cellIdx", "]", "indices", "for", "each", "of", "the", "active", "cells", "in", "activeInputs", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L47-L72
[ "def", "_labeledInput", "(", "activeInputs", ",", "cellsPerCol", "=", "32", ")", ":", "if", "cellsPerCol", "==", "0", ":", "cellsPerCol", "=", "1", "cols", "=", "activeInputs", ".", "size", "/", "cellsPerCol", "activeInputs", "=", "activeInputs", ".", "resha...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier.clear
Clears the state of the KNNClassifier.
src/nupic/algorithms/knn_classifier.py
def clear(self): """Clears the state of the KNNClassifier.""" self._Memory = None self._numPatterns = 0 self._M = None self._categoryList = [] self._partitionIdList = [] self._partitionIdMap = {} self._finishedLearning = False self._iterationIdx = -1 # Fixed capacity KNN if ...
def clear(self): """Clears the state of the KNNClassifier.""" self._Memory = None self._numPatterns = 0 self._M = None self._categoryList = [] self._partitionIdList = [] self._partitionIdMap = {} self._finishedLearning = False self._iterationIdx = -1 # Fixed capacity KNN if ...
[ "Clears", "the", "state", "of", "the", "KNNClassifier", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L226-L257
[ "def", "clear", "(", "self", ")", ":", "self", ".", "_Memory", "=", "None", "self", ".", "_numPatterns", "=", "0", "self", ".", "_M", "=", "None", "self", ".", "_categoryList", "=", "[", "]", "self", ".", "_partitionIdList", "=", "[", "]", "self", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier.prototypeSetCategory
Allows ids to be assigned a category and subsequently enables users to use: - :meth:`~.KNNClassifier.KNNClassifier.removeCategory` - :meth:`~.KNNClassifier.KNNClassifier.closestTrainingPattern` - :meth:`~.KNNClassifier.KNNClassifier.closestOtherTrainingPattern`
src/nupic/algorithms/knn_classifier.py
def prototypeSetCategory(self, idToCategorize, newCategory): """ Allows ids to be assigned a category and subsequently enables users to use: - :meth:`~.KNNClassifier.KNNClassifier.removeCategory` - :meth:`~.KNNClassifier.KNNClassifier.closestTrainingPattern` - :meth:`~.KNNClassifier.KNNClassi...
def prototypeSetCategory(self, idToCategorize, newCategory): """ Allows ids to be assigned a category and subsequently enables users to use: - :meth:`~.KNNClassifier.KNNClassifier.removeCategory` - :meth:`~.KNNClassifier.KNNClassifier.closestTrainingPattern` - :meth:`~.KNNClassifier.KNNClassi...
[ "Allows", "ids", "to", "be", "assigned", "a", "category", "and", "subsequently", "enables", "users", "to", "use", ":" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L294-L306
[ "def", "prototypeSetCategory", "(", "self", ",", "idToCategorize", ",", "newCategory", ")", ":", "if", "idToCategorize", "not", "in", "self", ".", "_categoryRecencyList", ":", "return", "recordIndex", "=", "self", ".", "_categoryRecencyList", ".", "index", "(", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier.removeIds
There are two caveats. First, this is a potentially slow operation. Second, pattern indices will shift if patterns before them are removed. :param idsToRemove: A list of row indices to remove.
src/nupic/algorithms/knn_classifier.py
def removeIds(self, idsToRemove): """ There are two caveats. First, this is a potentially slow operation. Second, pattern indices will shift if patterns before them are removed. :param idsToRemove: A list of row indices to remove. """ # Form a list of all categories to remove rowsToRemove =...
def removeIds(self, idsToRemove): """ There are two caveats. First, this is a potentially slow operation. Second, pattern indices will shift if patterns before them are removed. :param idsToRemove: A list of row indices to remove. """ # Form a list of all categories to remove rowsToRemove =...
[ "There", "are", "two", "caveats", ".", "First", "this", "is", "a", "potentially", "slow", "operation", ".", "Second", "pattern", "indices", "will", "shift", "if", "patterns", "before", "them", "are", "removed", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L309-L321
[ "def", "removeIds", "(", "self", ",", "idsToRemove", ")", ":", "# Form a list of all categories to remove", "rowsToRemove", "=", "[", "k", "for", "k", ",", "rowID", "in", "enumerate", "(", "self", ".", "_categoryRecencyList", ")", "if", "rowID", "in", "idsToRemo...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier.removeCategory
There are two caveats. First, this is a potentially slow operation. Second, pattern indices will shift if patterns before them are removed. :param categoryToRemove: Category label to remove
src/nupic/algorithms/knn_classifier.py
def removeCategory(self, categoryToRemove): """ There are two caveats. First, this is a potentially slow operation. Second, pattern indices will shift if patterns before them are removed. :param categoryToRemove: Category label to remove """ removedRows = 0 if self._Memory is None: re...
def removeCategory(self, categoryToRemove): """ There are two caveats. First, this is a potentially slow operation. Second, pattern indices will shift if patterns before them are removed. :param categoryToRemove: Category label to remove """ removedRows = 0 if self._Memory is None: re...
[ "There", "are", "two", "caveats", ".", "First", "this", "is", "a", "potentially", "slow", "operation", ".", "Second", "pattern", "indices", "will", "shift", "if", "patterns", "before", "them", "are", "removed", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L324-L346
[ "def", "removeCategory", "(", "self", ",", "categoryToRemove", ")", ":", "removedRows", "=", "0", "if", "self", ".", "_Memory", "is", "None", ":", "return", "removedRows", "# The internal category indices are stored in float", "# format, so we should compare with a float", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier._removeRows
A list of row indices to remove. There are two caveats. First, this is a potentially slow operation. Second, pattern indices will shift if patterns before them are removed.
src/nupic/algorithms/knn_classifier.py
def _removeRows(self, rowsToRemove): """ A list of row indices to remove. There are two caveats. First, this is a potentially slow operation. Second, pattern indices will shift if patterns before them are removed. """ # Form a numpy array of row indices to be removed removalArray = numpy.arr...
def _removeRows(self, rowsToRemove): """ A list of row indices to remove. There are two caveats. First, this is a potentially slow operation. Second, pattern indices will shift if patterns before them are removed. """ # Form a numpy array of row indices to be removed removalArray = numpy.arr...
[ "A", "list", "of", "row", "indices", "to", "remove", ".", "There", "are", "two", "caveats", ".", "First", "this", "is", "a", "potentially", "slow", "operation", ".", "Second", "pattern", "indices", "will", "shift", "if", "patterns", "before", "them", "are"...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L349-L393
[ "def", "_removeRows", "(", "self", ",", "rowsToRemove", ")", ":", "# Form a numpy array of row indices to be removed", "removalArray", "=", "numpy", ".", "array", "(", "rowsToRemove", ")", "# Remove categories", "self", ".", "_categoryList", "=", "numpy", ".", "delete...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier.learn
Train the classifier to associate specified input pattern with a particular category. :param inputPattern: (list) The pattern to be assigned a category. If isSparse is 0, this should be a dense array (both ON and OFF bits present). Otherwise, if isSparse > 0, this should be a list of the ...
src/nupic/algorithms/knn_classifier.py
def learn(self, inputPattern, inputCategory, partitionId=None, isSparse=0, rowID=None): """ Train the classifier to associate specified input pattern with a particular category. :param inputPattern: (list) The pattern to be assigned a category. If isSparse is 0, this should be a den...
def learn(self, inputPattern, inputCategory, partitionId=None, isSparse=0, rowID=None): """ Train the classifier to associate specified input pattern with a particular category. :param inputPattern: (list) The pattern to be assigned a category. If isSparse is 0, this should be a den...
[ "Train", "the", "classifier", "to", "associate", "specified", "input", "pattern", "with", "a", "particular", "category", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L404-L622
[ "def", "learn", "(", "self", ",", "inputPattern", ",", "inputCategory", ",", "partitionId", "=", "None", ",", "isSparse", "=", "0", ",", "rowID", "=", "None", ")", ":", "if", "self", ".", "verbosity", ">=", "1", ":", "print", "\"%s learn:\"", "%", "g_d...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier.getOverlaps
Return the degree of overlap between an input pattern and each category stored in the classifier. The overlap is computed by computing: .. code-block:: python logical_and(inputPattern != 0, trainingPattern != 0).sum() :param inputPattern: pattern to check overlap of :returns: (overlaps, catego...
src/nupic/algorithms/knn_classifier.py
def getOverlaps(self, inputPattern): """ Return the degree of overlap between an input pattern and each category stored in the classifier. The overlap is computed by computing: .. code-block:: python logical_and(inputPattern != 0, trainingPattern != 0).sum() :param inputPattern: pattern to ...
def getOverlaps(self, inputPattern): """ Return the degree of overlap between an input pattern and each category stored in the classifier. The overlap is computed by computing: .. code-block:: python logical_and(inputPattern != 0, trainingPattern != 0).sum() :param inputPattern: pattern to ...
[ "Return", "the", "degree", "of", "overlap", "between", "an", "input", "pattern", "and", "each", "category", "stored", "in", "the", "classifier", ".", "The", "overlap", "is", "computed", "by", "computing", ":" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L625-L644
[ "def", "getOverlaps", "(", "self", ",", "inputPattern", ")", ":", "assert", "self", ".", "useSparseMemory", ",", "\"Not implemented yet for dense storage\"", "overlaps", "=", "self", ".", "_Memory", ".", "rightVecSumAtNZ", "(", "inputPattern", ")", "return", "(", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier.getDistances
Return the distances between the input pattern and all other stored patterns. :param inputPattern: pattern to check distance with :returns: (distances, categories) numpy arrays of the same length. - overlaps: an integer overlap amount for each category - categories: category index for each...
src/nupic/algorithms/knn_classifier.py
def getDistances(self, inputPattern): """Return the distances between the input pattern and all other stored patterns. :param inputPattern: pattern to check distance with :returns: (distances, categories) numpy arrays of the same length. - overlaps: an integer overlap amount for each category ...
def getDistances(self, inputPattern): """Return the distances between the input pattern and all other stored patterns. :param inputPattern: pattern to check distance with :returns: (distances, categories) numpy arrays of the same length. - overlaps: an integer overlap amount for each category ...
[ "Return", "the", "distances", "between", "the", "input", "pattern", "and", "all", "other", "stored", "patterns", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L647-L658
[ "def", "getDistances", "(", "self", ",", "inputPattern", ")", ":", "dist", "=", "self", ".", "_getDistances", "(", "inputPattern", ")", "return", "(", "dist", ",", "self", ".", "_categoryList", ")" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier.infer
Finds the category that best matches the input pattern. Returns the winning category index as well as a distribution over all categories. :param inputPattern: (list or array) The pattern to be classified. This must be a dense representation of the array (e.g. [0, 0, 1, 1, 0, 1]). :param computeSco...
src/nupic/algorithms/knn_classifier.py
def infer(self, inputPattern, computeScores=True, overCategories=True, partitionId=None): """Finds the category that best matches the input pattern. Returns the winning category index as well as a distribution over all categories. :param inputPattern: (list or array) The pattern to be classifie...
def infer(self, inputPattern, computeScores=True, overCategories=True, partitionId=None): """Finds the category that best matches the input pattern. Returns the winning category index as well as a distribution over all categories. :param inputPattern: (list or array) The pattern to be classifie...
[ "Finds", "the", "category", "that", "best", "matches", "the", "input", "pattern", ".", "Returns", "the", "winning", "category", "index", "as", "well", "as", "a", "distribution", "over", "all", "categories", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L661-L754
[ "def", "infer", "(", "self", ",", "inputPattern", ",", "computeScores", "=", "True", ",", "overCategories", "=", "True", ",", "partitionId", "=", "None", ")", ":", "# Calculate sparsity. If sparsity is too low, we do not want to run", "# inference with this vector", "spar...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier.getClosest
Returns the index of the pattern that is closest to inputPattern, the distances of all patterns to inputPattern, and the indices of the k closest categories.
src/nupic/algorithms/knn_classifier.py
def getClosest(self, inputPattern, topKCategories=3): """Returns the index of the pattern that is closest to inputPattern, the distances of all patterns to inputPattern, and the indices of the k closest categories. """ inferenceResult = numpy.zeros(max(self._categoryList)+1) dist = self._getDist...
def getClosest(self, inputPattern, topKCategories=3): """Returns the index of the pattern that is closest to inputPattern, the distances of all patterns to inputPattern, and the indices of the k closest categories. """ inferenceResult = numpy.zeros(max(self._categoryList)+1) dist = self._getDist...
[ "Returns", "the", "index", "of", "the", "pattern", "that", "is", "closest", "to", "inputPattern", "the", "distances", "of", "all", "patterns", "to", "inputPattern", "and", "the", "indices", "of", "the", "k", "closest", "categories", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L757-L777
[ "def", "getClosest", "(", "self", ",", "inputPattern", ",", "topKCategories", "=", "3", ")", ":", "inferenceResult", "=", "numpy", ".", "zeros", "(", "max", "(", "self", ".", "_categoryList", ")", "+", "1", ")", "dist", "=", "self", ".", "_getDistances",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier.closestTrainingPattern
Returns the closest training pattern to inputPattern that belongs to category "cat". :param inputPattern: The pattern whose closest neighbor is sought :param cat: The required category of closest neighbor :returns: A dense version of the closest training pattern, or None if no such patterns e...
src/nupic/algorithms/knn_classifier.py
def closestTrainingPattern(self, inputPattern, cat): """Returns the closest training pattern to inputPattern that belongs to category "cat". :param inputPattern: The pattern whose closest neighbor is sought :param cat: The required category of closest neighbor :returns: A dense version of the clo...
def closestTrainingPattern(self, inputPattern, cat): """Returns the closest training pattern to inputPattern that belongs to category "cat". :param inputPattern: The pattern whose closest neighbor is sought :param cat: The required category of closest neighbor :returns: A dense version of the clo...
[ "Returns", "the", "closest", "training", "pattern", "to", "inputPattern", "that", "belongs", "to", "category", "cat", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L780-L807
[ "def", "closestTrainingPattern", "(", "self", ",", "inputPattern", ",", "cat", ")", ":", "dist", "=", "self", ".", "_getDistances", "(", "inputPattern", ")", "sorted", "=", "dist", ".", "argsort", "(", ")", "for", "patIdx", "in", "sorted", ":", "patternCat...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier.getPattern
Gets a training pattern either by index or category number. :param idx: Index of the training pattern :param sparseBinaryForm: If true, returns a list of the indices of the non-zero bits in the training pattern :param cat: If not None, get the first pattern belonging to category cat. If t...
src/nupic/algorithms/knn_classifier.py
def getPattern(self, idx, sparseBinaryForm=False, cat=None): """Gets a training pattern either by index or category number. :param idx: Index of the training pattern :param sparseBinaryForm: If true, returns a list of the indices of the non-zero bits in the training pattern :param cat: If not...
def getPattern(self, idx, sparseBinaryForm=False, cat=None): """Gets a training pattern either by index or category number. :param idx: Index of the training pattern :param sparseBinaryForm: If true, returns a list of the indices of the non-zero bits in the training pattern :param cat: If not...
[ "Gets", "a", "training", "pattern", "either", "by", "index", "or", "category", "number", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L840-L870
[ "def", "getPattern", "(", "self", ",", "idx", ",", "sparseBinaryForm", "=", "False", ",", "cat", "=", "None", ")", ":", "if", "cat", "is", "not", "None", ":", "assert", "idx", "is", "None", "idx", "=", "self", ".", "_categoryList", ".", "index", "(",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier.getPartitionId
Gets the partition id given an index. :param i: index of partition :returns: the partition id associated with pattern i. Returns None if no id is associated with it.
src/nupic/algorithms/knn_classifier.py
def getPartitionId(self, i): """ Gets the partition id given an index. :param i: index of partition :returns: the partition id associated with pattern i. Returns None if no id is associated with it. """ if (i < 0) or (i >= self._numPatterns): raise RuntimeError("index out of bound...
def getPartitionId(self, i): """ Gets the partition id given an index. :param i: index of partition :returns: the partition id associated with pattern i. Returns None if no id is associated with it. """ if (i < 0) or (i >= self._numPatterns): raise RuntimeError("index out of bound...
[ "Gets", "the", "partition", "id", "given", "an", "index", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L873-L887
[ "def", "getPartitionId", "(", "self", ",", "i", ")", ":", "if", "(", "i", "<", "0", ")", "or", "(", "i", ">=", "self", ".", "_numPatterns", ")", ":", "raise", "RuntimeError", "(", "\"index out of bounds\"", ")", "partitionId", "=", "self", ".", "_parti...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier._addPartitionId
Adds partition id for pattern index
src/nupic/algorithms/knn_classifier.py
def _addPartitionId(self, index, partitionId=None): """ Adds partition id for pattern index """ if partitionId is None: self._partitionIdList.append(numpy.inf) else: self._partitionIdList.append(partitionId) indices = self._partitionIdMap.get(partitionId, []) indices.append(i...
def _addPartitionId(self, index, partitionId=None): """ Adds partition id for pattern index """ if partitionId is None: self._partitionIdList.append(numpy.inf) else: self._partitionIdList.append(partitionId) indices = self._partitionIdMap.get(partitionId, []) indices.append(i...
[ "Adds", "partition", "id", "for", "pattern", "index" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L919-L929
[ "def", "_addPartitionId", "(", "self", ",", "index", ",", "partitionId", "=", "None", ")", ":", "if", "partitionId", "is", "None", ":", "self", ".", "_partitionIdList", ".", "append", "(", "numpy", ".", "inf", ")", "else", ":", "self", ".", "_partitionId...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier._rebuildPartitionIdMap
Rebuilds the partition Id map using the given partitionIdList
src/nupic/algorithms/knn_classifier.py
def _rebuildPartitionIdMap(self, partitionIdList): """ Rebuilds the partition Id map using the given partitionIdList """ self._partitionIdMap = {} for row, partitionId in enumerate(partitionIdList): indices = self._partitionIdMap.get(partitionId, []) indices.append(row) self._parti...
def _rebuildPartitionIdMap(self, partitionIdList): """ Rebuilds the partition Id map using the given partitionIdList """ self._partitionIdMap = {} for row, partitionId in enumerate(partitionIdList): indices = self._partitionIdMap.get(partitionId, []) indices.append(row) self._parti...
[ "Rebuilds", "the", "partition", "Id", "map", "using", "the", "given", "partitionIdList" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L932-L940
[ "def", "_rebuildPartitionIdMap", "(", "self", ",", "partitionIdList", ")", ":", "self", ".", "_partitionIdMap", "=", "{", "}", "for", "row", ",", "partitionId", "in", "enumerate", "(", "partitionIdList", ")", ":", "indices", "=", "self", ".", "_partitionIdMap"...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier._calcDistance
Calculate the distances from inputPattern to all stored patterns. All distances are between 0.0 and 1.0 :param inputPattern The pattern from which distances to all other patterns are calculated :param distanceNorm Degree of the distance norm
src/nupic/algorithms/knn_classifier.py
def _calcDistance(self, inputPattern, distanceNorm=None): """Calculate the distances from inputPattern to all stored patterns. All distances are between 0.0 and 1.0 :param inputPattern The pattern from which distances to all other patterns are calculated :param distanceNorm Degree of the dista...
def _calcDistance(self, inputPattern, distanceNorm=None): """Calculate the distances from inputPattern to all stored patterns. All distances are between 0.0 and 1.0 :param inputPattern The pattern from which distances to all other patterns are calculated :param distanceNorm Degree of the dista...
[ "Calculate", "the", "distances", "from", "inputPattern", "to", "all", "stored", "patterns", ".", "All", "distances", "are", "between", "0", ".", "0", "and", "1", ".", "0" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L943-L995
[ "def", "_calcDistance", "(", "self", ",", "inputPattern", ",", "distanceNorm", "=", "None", ")", ":", "if", "distanceNorm", "is", "None", ":", "distanceNorm", "=", "self", ".", "distanceNorm", "# Sparse memory", "if", "self", ".", "useSparseMemory", ":", "if",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier._getDistances
Return the distances from inputPattern to all stored patterns. :param inputPattern The pattern from which distances to all other patterns are returned :param partitionId If provided, ignore all training vectors with this partitionId.
src/nupic/algorithms/knn_classifier.py
def _getDistances(self, inputPattern, partitionId=None): """Return the distances from inputPattern to all stored patterns. :param inputPattern The pattern from which distances to all other patterns are returned :param partitionId If provided, ignore all training vectors with this partition...
def _getDistances(self, inputPattern, partitionId=None): """Return the distances from inputPattern to all stored patterns. :param inputPattern The pattern from which distances to all other patterns are returned :param partitionId If provided, ignore all training vectors with this partition...
[ "Return", "the", "distances", "from", "inputPattern", "to", "all", "stored", "patterns", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L998-L1026
[ "def", "_getDistances", "(", "self", ",", "inputPattern", ",", "partitionId", "=", "None", ")", ":", "if", "not", "self", ".", "_finishedLearning", ":", "self", ".", "finishLearning", "(", ")", "self", ".", "_finishedLearning", "=", "True", "if", "self", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier.computeSVD
Compute the singular value decomposition (SVD). The SVD is a factorization of a real or complex matrix. It factors the matrix `a` as `u * np.diag(s) * v`, where `u` and `v` are unitary and `s` is a 1-d array of `a`'s singular values. **Reason for computing the SVD:** There are cases where you ...
src/nupic/algorithms/knn_classifier.py
def computeSVD(self, numSVDSamples=0, finalize=True): """ Compute the singular value decomposition (SVD). The SVD is a factorization of a real or complex matrix. It factors the matrix `a` as `u * np.diag(s) * v`, where `u` and `v` are unitary and `s` is a 1-d array of `a`'s singular values. **R...
def computeSVD(self, numSVDSamples=0, finalize=True): """ Compute the singular value decomposition (SVD). The SVD is a factorization of a real or complex matrix. It factors the matrix `a` as `u * np.diag(s) * v`, where `u` and `v` are unitary and `s` is a 1-d array of `a`'s singular values. **R...
[ "Compute", "the", "singular", "value", "decomposition", "(", "SVD", ")", ".", "The", "SVD", "is", "a", "factorization", "of", "a", "real", "or", "complex", "matrix", ".", "It", "factors", "the", "matrix", "a", "as", "u", "*", "np", ".", "diag", "(", ...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L1038-L1080
[ "def", "computeSVD", "(", "self", ",", "numSVDSamples", "=", "0", ",", "finalize", "=", "True", ")", ":", "if", "numSVDSamples", "==", "0", ":", "numSVDSamples", "=", "self", ".", "_numPatterns", "if", "not", "self", ".", "useSparseMemory", ":", "self", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier.getAdaptiveSVDDims
Compute the number of eigenvectors (singularValues) to keep. :param singularValues: :param fractionOfMax: :return:
src/nupic/algorithms/knn_classifier.py
def getAdaptiveSVDDims(self, singularValues, fractionOfMax=0.001): """ Compute the number of eigenvectors (singularValues) to keep. :param singularValues: :param fractionOfMax: :return: """ v = singularValues/singularValues[0] idx = numpy.where(v<fractionOfMax)[0] if len(idx): ...
def getAdaptiveSVDDims(self, singularValues, fractionOfMax=0.001): """ Compute the number of eigenvectors (singularValues) to keep. :param singularValues: :param fractionOfMax: :return: """ v = singularValues/singularValues[0] idx = numpy.where(v<fractionOfMax)[0] if len(idx): ...
[ "Compute", "the", "number", "of", "eigenvectors", "(", "singularValues", ")", "to", "keep", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L1083-L1098
[ "def", "getAdaptiveSVDDims", "(", "self", ",", "singularValues", ",", "fractionOfMax", "=", "0.001", ")", ":", "v", "=", "singularValues", "/", "singularValues", "[", "0", "]", "idx", "=", "numpy", ".", "where", "(", "v", "<", "fractionOfMax", ")", "[", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier._finalizeSVD
Called by finalizeLearning(). This will project all the patterns onto the SVD eigenvectors. :param numSVDDims: (int) number of egeinvectors used for projection. :return:
src/nupic/algorithms/knn_classifier.py
def _finalizeSVD(self, numSVDDims=None): """ Called by finalizeLearning(). This will project all the patterns onto the SVD eigenvectors. :param numSVDDims: (int) number of egeinvectors used for projection. :return: """ if numSVDDims is not None: self.numSVDDims = numSVDDims if se...
def _finalizeSVD(self, numSVDDims=None): """ Called by finalizeLearning(). This will project all the patterns onto the SVD eigenvectors. :param numSVDDims: (int) number of egeinvectors used for projection. :return: """ if numSVDDims is not None: self.numSVDDims = numSVDDims if se...
[ "Called", "by", "finalizeLearning", "()", ".", "This", "will", "project", "all", "the", "patterns", "onto", "the", "SVD", "eigenvectors", ".", ":", "param", "numSVDDims", ":", "(", "int", ")", "number", "of", "egeinvectors", "used", "for", "projection", ".",...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L1101-L1140
[ "def", "_finalizeSVD", "(", "self", ",", "numSVDDims", "=", "None", ")", ":", "if", "numSVDDims", "is", "not", "None", ":", "self", ".", "numSVDDims", "=", "numSVDDims", "if", "self", ".", "numSVDDims", "==", "\"adaptive\"", ":", "if", "self", ".", "frac...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier.remapCategories
Change the category indices. Used by the Network Builder to keep the category indices in sync with the ImageSensor categoryInfo when the user renames or removes categories. :param mapping: List of new category indices. For example, mapping=[2,0,1] would change all vectors of category 0 to be categ...
src/nupic/algorithms/knn_classifier.py
def remapCategories(self, mapping): """Change the category indices. Used by the Network Builder to keep the category indices in sync with the ImageSensor categoryInfo when the user renames or removes categories. :param mapping: List of new category indices. For example, mapping=[2,0,1] would c...
def remapCategories(self, mapping): """Change the category indices. Used by the Network Builder to keep the category indices in sync with the ImageSensor categoryInfo when the user renames or removes categories. :param mapping: List of new category indices. For example, mapping=[2,0,1] would c...
[ "Change", "the", "category", "indices", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L1143-L1158
[ "def", "remapCategories", "(", "self", ",", "mapping", ")", ":", "categoryArray", "=", "numpy", ".", "array", "(", "self", ".", "_categoryList", ")", "newCategoryArray", "=", "numpy", ".", "zeros", "(", "categoryArray", ".", "shape", "[", "0", "]", ")", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
KNNClassifier.setCategoryOfVectors
Change the category associated with this vector(s). Used by the Network Builder to move vectors between categories, to enable categories, and to invalidate vectors by setting the category to -1. :param vectorIndices: Single index or list of indices :param categoryIndices: Single index or list of indi...
src/nupic/algorithms/knn_classifier.py
def setCategoryOfVectors(self, vectorIndices, categoryIndices): """Change the category associated with this vector(s). Used by the Network Builder to move vectors between categories, to enable categories, and to invalidate vectors by setting the category to -1. :param vectorIndices: Single index or li...
def setCategoryOfVectors(self, vectorIndices, categoryIndices): """Change the category associated with this vector(s). Used by the Network Builder to move vectors between categories, to enable categories, and to invalidate vectors by setting the category to -1. :param vectorIndices: Single index or li...
[ "Change", "the", "category", "associated", "with", "this", "vector", "(", "s", ")", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/knn_classifier.py#L1161-L1186
[ "def", "setCategoryOfVectors", "(", "self", ",", "vectorIndices", ",", "categoryIndices", ")", ":", "if", "not", "hasattr", "(", "vectorIndices", ",", "\"__iter__\"", ")", ":", "vectorIndices", "=", "[", "vectorIndices", "]", "categoryIndices", "=", "[", "catego...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RecordSensor.getNextRecord
Get the next record to encode. Includes getting a record from the `dataSource` and applying filters. If the filters request more data from the `dataSource` continue to get data from the `dataSource` until all filters are satisfied. This method is separate from :meth:`.RecordSensor.compute` so that we can...
src/nupic/regions/record_sensor.py
def getNextRecord(self): """ Get the next record to encode. Includes getting a record from the `dataSource` and applying filters. If the filters request more data from the `dataSource` continue to get data from the `dataSource` until all filters are satisfied. This method is separate from :meth:`...
def getNextRecord(self): """ Get the next record to encode. Includes getting a record from the `dataSource` and applying filters. If the filters request more data from the `dataSource` continue to get data from the `dataSource` until all filters are satisfied. This method is separate from :meth:`...
[ "Get", "the", "next", "record", "to", "encode", ".", "Includes", "getting", "a", "record", "from", "the", "dataSource", "and", "applying", "filters", ".", "If", "the", "filters", "request", "more", "data", "from", "the", "dataSource", "continue", "to", "get"...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/record_sensor.py#L272-L301
[ "def", "getNextRecord", "(", "self", ")", ":", "allFiltersHaveEnoughData", "=", "False", "while", "not", "allFiltersHaveEnoughData", ":", "# Get the data from the dataSource", "data", "=", "self", ".", "dataSource", ".", "getNextRecordDict", "(", ")", "if", "not", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RecordSensor.applyFilters
Apply pre-encoding filters. These filters may modify or add data. If a filter needs another record (e.g. a delta filter) it will request another record by returning False and the current record will be skipped (but will still be given to all filters). We have to be very careful about resets. A filte...
src/nupic/regions/record_sensor.py
def applyFilters(self, data): """ Apply pre-encoding filters. These filters may modify or add data. If a filter needs another record (e.g. a delta filter) it will request another record by returning False and the current record will be skipped (but will still be given to all filters). We hav...
def applyFilters(self, data): """ Apply pre-encoding filters. These filters may modify or add data. If a filter needs another record (e.g. a delta filter) it will request another record by returning False and the current record will be skipped (but will still be given to all filters). We hav...
[ "Apply", "pre", "-", "encoding", "filters", ".", "These", "filters", "may", "modify", "or", "add", "data", ".", "If", "a", "filter", "needs", "another", "record", "(", "e", ".", "g", ".", "a", "delta", "filter", ")", "it", "will", "request", "another",...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/record_sensor.py#L304-L337
[ "def", "applyFilters", "(", "self", ",", "data", ")", ":", "if", "self", ".", "verbosity", ">", "0", ":", "print", "\"RecordSensor got data: %s\"", "%", "data", "allFiltersHaveEnoughData", "=", "True", "if", "len", "(", "self", ".", "preEncodingFilters", ")", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RecordSensor.populateCategoriesOut
Populate the output array with the category indices. .. note:: Non-categories are represented with ``-1``. :param categories: (list) of category strings :param output: (list) category output, will be overwritten
src/nupic/regions/record_sensor.py
def populateCategoriesOut(self, categories, output): """ Populate the output array with the category indices. .. note:: Non-categories are represented with ``-1``. :param categories: (list) of category strings :param output: (list) category output, will be overwritten """ if categories...
def populateCategoriesOut(self, categories, output): """ Populate the output array with the category indices. .. note:: Non-categories are represented with ``-1``. :param categories: (list) of category strings :param output: (list) category output, will be overwritten """ if categories...
[ "Populate", "the", "output", "array", "with", "the", "category", "indices", ".", "..", "note", "::", "Non", "-", "categories", "are", "represented", "with", "-", "1", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/record_sensor.py#L340-L358
[ "def", "populateCategoriesOut", "(", "self", ",", "categories", ",", "output", ")", ":", "if", "categories", "[", "0", "]", "is", "None", ":", "# The record has no entry in category field.", "output", "[", ":", "]", "=", "-", "1", "else", ":", "# Populate cate...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RecordSensor.compute
Get a record from the dataSource and encode it. Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.compute`.
src/nupic/regions/record_sensor.py
def compute(self, inputs, outputs): """ Get a record from the dataSource and encode it. Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.compute`. """ if not self.topDownMode: data = self.getNextRecord() # The private keys in data are standard of RecordStreamIface objects....
def compute(self, inputs, outputs): """ Get a record from the dataSource and encode it. Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.compute`. """ if not self.topDownMode: data = self.getNextRecord() # The private keys in data are standard of RecordStreamIface objects....
[ "Get", "a", "record", "from", "the", "dataSource", "and", "encode", "it", ".", "Overrides", ":", "meth", ":", "nupic", ".", "bindings", ".", "regions", ".", "PyRegion", ".", "PyRegion", ".", "compute", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/record_sensor.py#L361-L504
[ "def", "compute", "(", "self", ",", "inputs", ",", "outputs", ")", ":", "if", "not", "self", ".", "topDownMode", ":", "data", "=", "self", ".", "getNextRecord", "(", ")", "# The private keys in data are standard of RecordStreamIface objects. Any", "# add'l keys are co...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RecordSensor._convertNonNumericData
Converts all of the non-numeric fields from spatialOutput and temporalOutput into their scalar equivalents and records them in the output dictionary. :param spatialOutput: The results of topDownCompute() for the spatial input. :param temporalOutput: The results of topDownCompute() for the temporal in...
src/nupic/regions/record_sensor.py
def _convertNonNumericData(self, spatialOutput, temporalOutput, output): """ Converts all of the non-numeric fields from spatialOutput and temporalOutput into their scalar equivalents and records them in the output dictionary. :param spatialOutput: The results of topDownCompute() for the spatial input....
def _convertNonNumericData(self, spatialOutput, temporalOutput, output): """ Converts all of the non-numeric fields from spatialOutput and temporalOutput into their scalar equivalents and records them in the output dictionary. :param spatialOutput: The results of topDownCompute() for the spatial input....
[ "Converts", "all", "of", "the", "non", "-", "numeric", "fields", "from", "spatialOutput", "and", "temporalOutput", "into", "their", "scalar", "equivalents", "and", "records", "them", "in", "the", "output", "dictionary", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/record_sensor.py#L507-L533
[ "def", "_convertNonNumericData", "(", "self", ",", "spatialOutput", ",", "temporalOutput", ",", "output", ")", ":", "encoders", "=", "self", ".", "encoder", ".", "getEncoderList", "(", ")", "types", "=", "self", ".", "encoder", ".", "getDecoderOutputFieldTypes",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RecordSensor.getOutputElementCount
Computes the width of dataOut. Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.getOutputElementCount`.
src/nupic/regions/record_sensor.py
def getOutputElementCount(self, name): """ Computes the width of dataOut. Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.getOutputElementCount`. """ if name == "resetOut": print ("WARNING: getOutputElementCount should not have been called with " "resetOut") ...
def getOutputElementCount(self, name): """ Computes the width of dataOut. Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.getOutputElementCount`. """ if name == "resetOut": print ("WARNING: getOutputElementCount should not have been called with " "resetOut") ...
[ "Computes", "the", "width", "of", "dataOut", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/record_sensor.py#L547-L595
[ "def", "getOutputElementCount", "(", "self", ",", "name", ")", ":", "if", "name", "==", "\"resetOut\"", ":", "print", "(", "\"WARNING: getOutputElementCount should not have been called with \"", "\"resetOut\"", ")", "return", "1", "elif", "name", "==", "\"sequenceIdOut\...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RecordSensor.setParameter
Set the value of a Spec parameter. Most parameters are handled automatically by PyRegion's parameter set mechanism. The ones that need special treatment are explicitly handled here.
src/nupic/regions/record_sensor.py
def setParameter(self, parameterName, index, parameterValue): """ Set the value of a Spec parameter. Most parameters are handled automatically by PyRegion's parameter set mechanism. The ones that need special treatment are explicitly handled here. """ if parameterName == 'topDownMode': ...
def setParameter(self, parameterName, index, parameterValue): """ Set the value of a Spec parameter. Most parameters are handled automatically by PyRegion's parameter set mechanism. The ones that need special treatment are explicitly handled here. """ if parameterName == 'topDownMode': ...
[ "Set", "the", "value", "of", "a", "Spec", "parameter", ".", "Most", "parameters", "are", "handled", "automatically", "by", "PyRegion", "s", "parameter", "set", "mechanism", ".", "The", "ones", "that", "need", "special", "treatment", "are", "explicitly", "handl...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/record_sensor.py#L598-L609
[ "def", "setParameter", "(", "self", ",", "parameterName", ",", "index", ",", "parameterValue", ")", ":", "if", "parameterName", "==", "'topDownMode'", ":", "self", ".", "topDownMode", "=", "parameterValue", "elif", "parameterName", "==", "'predictedField'", ":", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RecordSensor.writeToProto
Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.writeToProto`.
src/nupic/regions/record_sensor.py
def writeToProto(self, proto): """ Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.writeToProto`. """ self.encoder.write(proto.encoder) if self.disabledEncoder is not None: self.disabledEncoder.write(proto.disabledEncoder) proto.topDownMode = int(self.topDownMode) proto.verbo...
def writeToProto(self, proto): """ Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.writeToProto`. """ self.encoder.write(proto.encoder) if self.disabledEncoder is not None: self.disabledEncoder.write(proto.disabledEncoder) proto.topDownMode = int(self.topDownMode) proto.verbo...
[ "Overrides", ":", "meth", ":", "nupic", ".", "bindings", ".", "regions", ".", "PyRegion", ".", "PyRegion", ".", "writeToProto", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/record_sensor.py#L620-L629
[ "def", "writeToProto", "(", "self", ",", "proto", ")", ":", "self", ".", "encoder", ".", "write", "(", "proto", ".", "encoder", ")", "if", "self", ".", "disabledEncoder", "is", "not", "None", ":", "self", ".", "disabledEncoder", ".", "write", "(", "pro...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
RecordSensor.readFromProto
Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.readFromProto`.
src/nupic/regions/record_sensor.py
def readFromProto(cls, proto): """ Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.readFromProto`. """ instance = cls() instance.encoder = MultiEncoder.read(proto.encoder) if proto.disabledEncoder is not None: instance.disabledEncoder = MultiEncoder.read(proto.disabledEncode...
def readFromProto(cls, proto): """ Overrides :meth:`nupic.bindings.regions.PyRegion.PyRegion.readFromProto`. """ instance = cls() instance.encoder = MultiEncoder.read(proto.encoder) if proto.disabledEncoder is not None: instance.disabledEncoder = MultiEncoder.read(proto.disabledEncode...
[ "Overrides", ":", "meth", ":", "nupic", ".", "bindings", ".", "regions", ".", "PyRegion", ".", "PyRegion", ".", "readFromProto", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/record_sensor.py#L633-L646
[ "def", "readFromProto", "(", "cls", ",", "proto", ")", ":", "instance", "=", "cls", "(", ")", "instance", ".", "encoder", "=", "MultiEncoder", ".", "read", "(", "proto", ".", "encoder", ")", "if", "proto", ".", "disabledEncoder", "is", "not", "None", "...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
computeAccuracy
Compute prediction accuracy by checking if the next page in the sequence is within the top N predictions calculated by the model Args: model: HTM model size: Sample size top: top N predictions to use Returns: Probability the next page in the sequence is within the top N predicted pages
examples/prediction/category_prediction/webdata.py
def computeAccuracy(model, size, top): """ Compute prediction accuracy by checking if the next page in the sequence is within the top N predictions calculated by the model Args: model: HTM model size: Sample size top: top N predictions to use Returns: Probability the next page in the sequence is ...
def computeAccuracy(model, size, top): """ Compute prediction accuracy by checking if the next page in the sequence is within the top N predictions calculated by the model Args: model: HTM model size: Sample size top: top N predictions to use Returns: Probability the next page in the sequence is ...
[ "Compute", "prediction", "accuracy", "by", "checking", "if", "the", "next", "page", "in", "the", "sequence", "is", "within", "the", "top", "N", "predictions", "calculated", "by", "the", "model", "Args", ":", "model", ":", "HTM", "model", "size", ":", "Samp...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/prediction/category_prediction/webdata.py#L146-L187
[ "def", "computeAccuracy", "(", "model", ",", "size", ",", "top", ")", ":", "accuracy", "=", "[", "]", "# Load MSNBC web data file", "filename", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "\"m...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
readUserSession
Reads the user session record from the file's cursor position Args: datafile: Data file whose cursor points at the beginning of the record Returns: list of pages in the order clicked by the user
examples/prediction/category_prediction/webdata.py
def readUserSession(datafile): """ Reads the user session record from the file's cursor position Args: datafile: Data file whose cursor points at the beginning of the record Returns: list of pages in the order clicked by the user """ for line in datafile: pages = line.split() total = len(pa...
def readUserSession(datafile): """ Reads the user session record from the file's cursor position Args: datafile: Data file whose cursor points at the beginning of the record Returns: list of pages in the order clicked by the user """ for line in datafile: pages = line.split() total = len(pa...
[ "Reads", "the", "user", "session", "record", "from", "the", "file", "s", "cursor", "position", "Args", ":", "datafile", ":", "Data", "file", "whose", "cursor", "points", "at", "the", "beginning", "of", "the", "record" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/prediction/category_prediction/webdata.py#L191-L212
[ "def", "readUserSession", "(", "datafile", ")", ":", "for", "line", "in", "datafile", ":", "pages", "=", "line", ".", "split", "(", ")", "total", "=", "len", "(", "pages", ")", "# Select user sessions with 2 or more pages", "if", "total", "<", "2", ":", "c...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
FileRecordStream.rewind
Put us back at the beginning of the file again.
src/nupic/data/file_record_stream.py
def rewind(self): """ Put us back at the beginning of the file again. """ # Superclass rewind super(FileRecordStream, self).rewind() self.close() self._file = open(self._filename, self._mode) self._reader = csv.reader(self._file, dialect="excel") # Skip header rows self._reade...
def rewind(self): """ Put us back at the beginning of the file again. """ # Superclass rewind super(FileRecordStream, self).rewind() self.close() self._file = open(self._filename, self._mode) self._reader = csv.reader(self._file, dialect="excel") # Skip header rows self._reade...
[ "Put", "us", "back", "at", "the", "beginning", "of", "the", "file", "again", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/file_record_stream.py#L322-L340
[ "def", "rewind", "(", "self", ")", ":", "# Superclass rewind", "super", "(", "FileRecordStream", ",", "self", ")", ".", "rewind", "(", ")", "self", ".", "close", "(", ")", "self", ".", "_file", "=", "open", "(", "self", ".", "_filename", ",", "self", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
FileRecordStream.getNextRecord
Returns next available data record from the file. :returns: a data row (a list or tuple) if available; None, if no more records in the table (End of Stream - EOS); empty sequence (list or tuple) when timing out while waiting for the next record.
src/nupic/data/file_record_stream.py
def getNextRecord(self, useCache=True): """ Returns next available data record from the file. :returns: a data row (a list or tuple) if available; None, if no more records in the table (End of Stream - EOS); empty sequence (list or tuple) when timing out while waiting for the next r...
def getNextRecord(self, useCache=True): """ Returns next available data record from the file. :returns: a data row (a list or tuple) if available; None, if no more records in the table (End of Stream - EOS); empty sequence (list or tuple) when timing out while waiting for the next r...
[ "Returns", "next", "available", "data", "record", "from", "the", "file", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/file_record_stream.py#L343-L387
[ "def", "getNextRecord", "(", "self", ",", "useCache", "=", "True", ")", ":", "assert", "self", ".", "_file", "is", "not", "None", "assert", "self", ".", "_mode", "==", "self", ".", "_FILE_READ_MODE", "# Read the line", "try", ":", "line", "=", "self", "....
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
FileRecordStream.appendRecord
Saves the record in the underlying csv file. :param record: a list of Python objects that will be string-ified
src/nupic/data/file_record_stream.py
def appendRecord(self, record): """ Saves the record in the underlying csv file. :param record: a list of Python objects that will be string-ified """ assert self._file is not None assert self._mode == self._FILE_WRITE_MODE assert isinstance(record, (list, tuple)), \ "unexpected reco...
def appendRecord(self, record): """ Saves the record in the underlying csv file. :param record: a list of Python objects that will be string-ified """ assert self._file is not None assert self._mode == self._FILE_WRITE_MODE assert isinstance(record, (list, tuple)), \ "unexpected reco...
[ "Saves", "the", "record", "in", "the", "underlying", "csv", "file", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/file_record_stream.py#L390-L418
[ "def", "appendRecord", "(", "self", ",", "record", ")", ":", "assert", "self", ".", "_file", "is", "not", "None", "assert", "self", ".", "_mode", "==", "self", ".", "_FILE_WRITE_MODE", "assert", "isinstance", "(", "record", ",", "(", "list", ",", "tuple"...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
FileRecordStream.appendRecords
Saves multiple records in the underlying storage. :param records: array of records as in :meth:`~.FileRecordStream.appendRecord` :param progressCB: (function) callback to report progress
src/nupic/data/file_record_stream.py
def appendRecords(self, records, progressCB=None): """ Saves multiple records in the underlying storage. :param records: array of records as in :meth:`~.FileRecordStream.appendRecord` :param progressCB: (function) callback to report progress """ for record in records: ...
def appendRecords(self, records, progressCB=None): """ Saves multiple records in the underlying storage. :param records: array of records as in :meth:`~.FileRecordStream.appendRecord` :param progressCB: (function) callback to report progress """ for record in records: ...
[ "Saves", "multiple", "records", "in", "the", "underlying", "storage", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/file_record_stream.py#L421-L433
[ "def", "appendRecords", "(", "self", ",", "records", ",", "progressCB", "=", "None", ")", ":", "for", "record", "in", "records", ":", "self", ".", "appendRecord", "(", "record", ")", "if", "progressCB", "is", "not", "None", ":", "progressCB", "(", ")" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
FileRecordStream.getBookmark
Gets a bookmark or anchor to the current position. :returns: an anchor to the current position in the data. Passing this anchor to a constructor makes the current position to be the first returned record.
src/nupic/data/file_record_stream.py
def getBookmark(self): """ Gets a bookmark or anchor to the current position. :returns: an anchor to the current position in the data. Passing this anchor to a constructor makes the current position to be the first returned record. """ if self._write and self._recordCou...
def getBookmark(self): """ Gets a bookmark or anchor to the current position. :returns: an anchor to the current position in the data. Passing this anchor to a constructor makes the current position to be the first returned record. """ if self._write and self._recordCou...
[ "Gets", "a", "bookmark", "or", "anchor", "to", "the", "current", "position", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/file_record_stream.py#L436-L450
[ "def", "getBookmark", "(", "self", ")", ":", "if", "self", ".", "_write", "and", "self", ".", "_recordCount", "==", "0", ":", "return", "None", "rowDict", "=", "dict", "(", "filepath", "=", "os", ".", "path", ".", "realpath", "(", "self", ".", "_file...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
FileRecordStream.seekFromEnd
Seeks to ``numRecords`` from the end and returns a bookmark to the new position. :param numRecords: how far to seek from end of file. :return: bookmark to desired location.
src/nupic/data/file_record_stream.py
def seekFromEnd(self, numRecords): """ Seeks to ``numRecords`` from the end and returns a bookmark to the new position. :param numRecords: how far to seek from end of file. :return: bookmark to desired location. """ self._file.seek(self._getTotalLineCount() - numRecords) return self.get...
def seekFromEnd(self, numRecords): """ Seeks to ``numRecords`` from the end and returns a bookmark to the new position. :param numRecords: how far to seek from end of file. :return: bookmark to desired location. """ self._file.seek(self._getTotalLineCount() - numRecords) return self.get...
[ "Seeks", "to", "numRecords", "from", "the", "end", "and", "returns", "a", "bookmark", "to", "the", "new", "position", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/file_record_stream.py#L463-L472
[ "def", "seekFromEnd", "(", "self", ",", "numRecords", ")", ":", "self", ".", "_file", ".", "seek", "(", "self", ".", "_getTotalLineCount", "(", ")", "-", "numRecords", ")", "return", "self", ".", "getBookmark", "(", ")" ]
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
FileRecordStream.getStats
Parse the file using dedicated reader and collect fields stats. Never called if user of :class:`~.FileRecordStream` does not invoke :meth:`~.FileRecordStream.getStats` method. :returns: a dictionary of stats. In the current implementation, min and max fields are supported. Example of th...
src/nupic/data/file_record_stream.py
def getStats(self): """ Parse the file using dedicated reader and collect fields stats. Never called if user of :class:`~.FileRecordStream` does not invoke :meth:`~.FileRecordStream.getStats` method. :returns: a dictionary of stats. In the current implementation, min and max fie...
def getStats(self): """ Parse the file using dedicated reader and collect fields stats. Never called if user of :class:`~.FileRecordStream` does not invoke :meth:`~.FileRecordStream.getStats` method. :returns: a dictionary of stats. In the current implementation, min and max fie...
[ "Parse", "the", "file", "using", "dedicated", "reader", "and", "collect", "fields", "stats", ".", "Never", "called", "if", "user", "of", ":", "class", ":", "~", ".", "FileRecordStream", "does", "not", "invoke", ":", "meth", ":", "~", ".", "FileRecordStream...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/file_record_stream.py#L490-L555
[ "def", "getStats", "(", "self", ")", ":", "# Collect stats only once per File object, use fresh csv iterator", "# to keep the next() method returning sequential records no matter when", "# caller asks for stats", "if", "self", ".", "_stats", "==", "None", ":", "# Stats are only avail...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
FileRecordStream._updateSequenceInfo
Keep track of sequence and make sure time goes forward Check if the current record is the beginning of a new sequence A new sequence starts in 2 cases: 1. The sequence id changed (if there is a sequence id field) 2. The reset field is 1 (if there is a reset field) Note that if there is no sequenc...
src/nupic/data/file_record_stream.py
def _updateSequenceInfo(self, r): """Keep track of sequence and make sure time goes forward Check if the current record is the beginning of a new sequence A new sequence starts in 2 cases: 1. The sequence id changed (if there is a sequence id field) 2. The reset field is 1 (if there is a reset fie...
def _updateSequenceInfo(self, r): """Keep track of sequence and make sure time goes forward Check if the current record is the beginning of a new sequence A new sequence starts in 2 cases: 1. The sequence id changed (if there is a sequence id field) 2. The reset field is 1 (if there is a reset fie...
[ "Keep", "track", "of", "sequence", "and", "make", "sure", "time", "goes", "forward" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/file_record_stream.py#L609-L659
[ "def", "_updateSequenceInfo", "(", "self", ",", "r", ")", ":", "# Get current sequence id (if any)", "newSequence", "=", "False", "sequenceId", "=", "(", "r", "[", "self", ".", "_sequenceIdIdx", "]", "if", "self", ".", "_sequenceIdIdx", "is", "not", "None", "e...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
FileRecordStream._getStartRow
Extracts start row from the bookmark information
src/nupic/data/file_record_stream.py
def _getStartRow(self, bookmark): """ Extracts start row from the bookmark information """ bookMarkDict = json.loads(bookmark) realpath = os.path.realpath(self._filename) bookMarkFile = bookMarkDict.get('filepath', None) if bookMarkFile != realpath: print ("Ignoring bookmark due to mism...
def _getStartRow(self, bookmark): """ Extracts start row from the bookmark information """ bookMarkDict = json.loads(bookmark) realpath = os.path.realpath(self._filename) bookMarkFile = bookMarkDict.get('filepath', None) if bookMarkFile != realpath: print ("Ignoring bookmark due to mism...
[ "Extracts", "start", "row", "from", "the", "bookmark", "information" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/file_record_stream.py#L662-L677
[ "def", "_getStartRow", "(", "self", ",", "bookmark", ")", ":", "bookMarkDict", "=", "json", ".", "loads", "(", "bookmark", ")", "realpath", "=", "os", ".", "path", ".", "realpath", "(", "self", ".", "_filename", ")", "bookMarkFile", "=", "bookMarkDict", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
FileRecordStream._getTotalLineCount
Returns: count of ALL lines in dataset, including header lines
src/nupic/data/file_record_stream.py
def _getTotalLineCount(self): """ Returns: count of ALL lines in dataset, including header lines """ # Flush the file before we open it again to count lines if self._mode == self._FILE_WRITE_MODE: self._file.flush() return sum(1 for line in open(self._filename, self._FILE_READ_MODE))
def _getTotalLineCount(self): """ Returns: count of ALL lines in dataset, including header lines """ # Flush the file before we open it again to count lines if self._mode == self._FILE_WRITE_MODE: self._file.flush() return sum(1 for line in open(self._filename, self._FILE_READ_MODE))
[ "Returns", ":", "count", "of", "ALL", "lines", "in", "dataset", "including", "header", "lines" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/file_record_stream.py#L680-L686
[ "def", "_getTotalLineCount", "(", "self", ")", ":", "# Flush the file before we open it again to count lines", "if", "self", ".", "_mode", "==", "self", ".", "_FILE_WRITE_MODE", ":", "self", ".", "_file", ".", "flush", "(", ")", "return", "sum", "(", "1", "for",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
FileRecordStream.getDataRowCount
:returns: (int) count of data rows in dataset (excluding header lines)
src/nupic/data/file_record_stream.py
def getDataRowCount(self): """ :returns: (int) count of data rows in dataset (excluding header lines) """ numLines = self._getTotalLineCount() if numLines == 0: # this may be the case in a file opened for write before the # header rows are written out assert self._mode == self._FI...
def getDataRowCount(self): """ :returns: (int) count of data rows in dataset (excluding header lines) """ numLines = self._getTotalLineCount() if numLines == 0: # this may be the case in a file opened for write before the # header rows are written out assert self._mode == self._FI...
[ ":", "returns", ":", "(", "int", ")", "count", "of", "data", "rows", "in", "dataset", "(", "excluding", "header", "lines", ")" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/file_record_stream.py#L697-L713
[ "def", "getDataRowCount", "(", "self", ")", ":", "numLines", "=", "self", ".", "_getTotalLineCount", "(", ")", "if", "numLines", "==", "0", ":", "# this may be the case in a file opened for write before the", "# header rows are written out", "assert", "self", ".", "_mod...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
runIoThroughNupic
Handles looping over the input data and passing each row into the given model object, as well as extracting the result object and passing it into an output handler. :param inputData: file path to input data CSV :param model: OPF Model object :param gymName: Gym name, used for output handler naming :param pl...
examples/opf/clients/hotgym/anomaly/one_gym/run.py
def runIoThroughNupic(inputData, model, gymName, plot): """ Handles looping over the input data and passing each row into the given model object, as well as extracting the result object and passing it into an output handler. :param inputData: file path to input data CSV :param model: OPF Model object :par...
def runIoThroughNupic(inputData, model, gymName, plot): """ Handles looping over the input data and passing each row into the given model object, as well as extracting the result object and passing it into an output handler. :param inputData: file path to input data CSV :param model: OPF Model object :par...
[ "Handles", "looping", "over", "the", "input", "data", "and", "passing", "each", "row", "into", "the", "given", "model", "object", "as", "well", "as", "extracting", "the", "result", "object", "and", "passing", "it", "into", "an", "output", "handler", ".", "...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/opf/clients/hotgym/anomaly/one_gym/run.py#L82-L125
[ "def", "runIoThroughNupic", "(", "inputData", ",", "model", ",", "gymName", ",", "plot", ")", ":", "inputFile", "=", "open", "(", "inputData", ",", "\"rb\"", ")", "csvReader", "=", "csv", ".", "reader", "(", "inputFile", ")", "# skip header rows", "csvReader...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
DeltaEncoder.topDownCompute
[ScalarEncoder class method override]
src/nupic/encoders/delta.py
def topDownCompute(self, encoded): """[ScalarEncoder class method override]""" #Decode to delta scalar if self._prevAbsolute==None or self._prevDelta==None: return [EncoderResult(value=0, scalar=0, encoding=numpy.zeros(self.n))] ret = self._adaptiveScalarEnc.topDownCo...
def topDownCompute(self, encoded): """[ScalarEncoder class method override]""" #Decode to delta scalar if self._prevAbsolute==None or self._prevDelta==None: return [EncoderResult(value=0, scalar=0, encoding=numpy.zeros(self.n))] ret = self._adaptiveScalarEnc.topDownCo...
[ "[", "ScalarEncoder", "class", "method", "override", "]" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/delta.py#L102-L116
[ "def", "topDownCompute", "(", "self", ",", "encoded", ")", ":", "#Decode to delta scalar", "if", "self", ".", "_prevAbsolute", "==", "None", "or", "self", ".", "_prevDelta", "==", "None", ":", "return", "[", "EncoderResult", "(", "value", "=", "0", ",", "s...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
InferenceElement.isTemporal
Returns True if the inference from this timestep is predicted the input for the NEXT timestep. NOTE: This should only be checked IF THE MODEL'S INFERENCE TYPE IS ALSO TEMPORAL. That is, a temporal model CAN have non-temporal inference elements, but a non-temporal model CANNOT have temporal inference el...
src/nupic/swarming/experiment_utils.py
def isTemporal(inferenceElement): """ Returns True if the inference from this timestep is predicted the input for the NEXT timestep. NOTE: This should only be checked IF THE MODEL'S INFERENCE TYPE IS ALSO TEMPORAL. That is, a temporal model CAN have non-temporal inference elements, but a non-tempor...
def isTemporal(inferenceElement): """ Returns True if the inference from this timestep is predicted the input for the NEXT timestep. NOTE: This should only be checked IF THE MODEL'S INFERENCE TYPE IS ALSO TEMPORAL. That is, a temporal model CAN have non-temporal inference elements, but a non-tempor...
[ "Returns", "True", "if", "the", "inference", "from", "this", "timestep", "is", "predicted", "the", "input", "for", "the", "NEXT", "timestep", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/experiment_utils.py#L66-L78
[ "def", "isTemporal", "(", "inferenceElement", ")", ":", "if", "InferenceElement", ".", "__temporalInferenceElements", "is", "None", ":", "InferenceElement", ".", "__temporalInferenceElements", "=", "set", "(", "[", "InferenceElement", ".", "prediction", "]", ")", "r...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
InferenceElement.getTemporalDelay
Returns the number of records that elapse between when an inference is made and when the corresponding input record will appear. For example, a multistep prediction for 3 timesteps out will have a delay of 3 Parameters: ----------------------------------------------------------------------- infer...
src/nupic/swarming/experiment_utils.py
def getTemporalDelay(inferenceElement, key=None): """ Returns the number of records that elapse between when an inference is made and when the corresponding input record will appear. For example, a multistep prediction for 3 timesteps out will have a delay of 3 Parameters: ------------------------...
def getTemporalDelay(inferenceElement, key=None): """ Returns the number of records that elapse between when an inference is made and when the corresponding input record will appear. For example, a multistep prediction for 3 timesteps out will have a delay of 3 Parameters: ------------------------...
[ "Returns", "the", "number", "of", "records", "that", "elapse", "between", "when", "an", "inference", "is", "made", "and", "when", "the", "corresponding", "input", "record", "will", "appear", ".", "For", "example", "a", "multistep", "prediction", "for", "3", ...
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/experiment_utils.py#L81-L116
[ "def", "getTemporalDelay", "(", "inferenceElement", ",", "key", "=", "None", ")", ":", "# -----------------------------------------------------------------------", "# For next step prediction, we shift by 1", "if", "inferenceElement", "in", "(", "InferenceElement", ".", "predicti...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
InferenceElement.getMaxDelay
Returns the maximum delay for the InferenceElements in the inference dictionary Parameters: ----------------------------------------------------------------------- inferences: A dictionary where the keys are InferenceElements
src/nupic/swarming/experiment_utils.py
def getMaxDelay(inferences): """ Returns the maximum delay for the InferenceElements in the inference dictionary Parameters: ----------------------------------------------------------------------- inferences: A dictionary where the keys are InferenceElements """ maxDelay = 0 for i...
def getMaxDelay(inferences): """ Returns the maximum delay for the InferenceElements in the inference dictionary Parameters: ----------------------------------------------------------------------- inferences: A dictionary where the keys are InferenceElements """ maxDelay = 0 for i...
[ "Returns", "the", "maximum", "delay", "for", "the", "InferenceElements", "in", "the", "inference", "dictionary" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/experiment_utils.py#L119-L140
[ "def", "getMaxDelay", "(", "inferences", ")", ":", "maxDelay", "=", "0", "for", "inferenceElement", ",", "inference", "in", "inferences", ".", "iteritems", "(", ")", ":", "if", "isinstance", "(", "inference", ",", "dict", ")", ":", "for", "key", "in", "i...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
InferenceType.isTemporal
Returns True if the inference type is 'temporal', i.e. requires a temporal memory in the network.
src/nupic/swarming/experiment_utils.py
def isTemporal(inferenceType): """ Returns True if the inference type is 'temporal', i.e. requires a temporal memory in the network. """ if InferenceType.__temporalInferenceTypes is None: InferenceType.__temporalInferenceTypes = \ set([InferenceType.TemporalNextStep...
def isTemporal(inferenceType): """ Returns True if the inference type is 'temporal', i.e. requires a temporal memory in the network. """ if InferenceType.__temporalInferenceTypes is None: InferenceType.__temporalInferenceTypes = \ set([InferenceType.TemporalNextStep...
[ "Returns", "True", "if", "the", "inference", "type", "is", "temporal", "i", ".", "e", ".", "requires", "a", "temporal", "memory", "in", "the", "network", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/experiment_utils.py#L154-L166
[ "def", "isTemporal", "(", "inferenceType", ")", ":", "if", "InferenceType", ".", "__temporalInferenceTypes", "is", "None", ":", "InferenceType", ".", "__temporalInferenceTypes", "=", "set", "(", "[", "InferenceType", ".", "TemporalNextStep", ",", "InferenceType", "....
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
Enum
Utility function for creating enumerations in python Example Usage: >> Color = Enum("Red", "Green", "Blue", "Magenta") >> print Color.Red >> 0 >> print Color.Green >> 1 >> print Color.Blue >> 2 >> print Color.Magenta >> 3 >> Color.Violet >> 'violet' >> Color.getLabel(C...
src/nupic/swarming/hypersearch/support.py
def Enum(*args, **kwargs): """ Utility function for creating enumerations in python Example Usage: >> Color = Enum("Red", "Green", "Blue", "Magenta") >> print Color.Red >> 0 >> print Color.Green >> 1 >> print Color.Blue >> 2 >> print Color.Magenta >> 3 >> Color.Violet ...
def Enum(*args, **kwargs): """ Utility function for creating enumerations in python Example Usage: >> Color = Enum("Red", "Green", "Blue", "Magenta") >> print Color.Red >> 0 >> print Color.Green >> 1 >> print Color.Blue >> 2 >> print Color.Magenta >> 3 >> Color.Violet ...
[ "Utility", "function", "for", "creating", "enumerations", "in", "python" ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/support.py#L50-L113
[ "def", "Enum", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "getLabel", "(", "cls", ",", "val", ")", ":", "\"\"\" Get a string label for the current value of the enum \"\"\"", "return", "cls", ".", "__labels", "[", "val", "]", "def", "validate",...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
makeDirectoryFromAbsolutePath
Makes directory for the given directory path with default permissions. If the directory already exists, it is treated as success. absDirPath: absolute path of the directory to create. Returns: absDirPath arg Exceptions: OSError if directory creation fails
src/nupic/swarming/hypersearch/support.py
def makeDirectoryFromAbsolutePath(absDirPath): """ Makes directory for the given directory path with default permissions. If the directory already exists, it is treated as success. absDirPath: absolute path of the directory to create. Returns: absDirPath arg Exceptions: OSError if directory ...
def makeDirectoryFromAbsolutePath(absDirPath): """ Makes directory for the given directory path with default permissions. If the directory already exists, it is treated as success. absDirPath: absolute path of the directory to create. Returns: absDirPath arg Exceptions: OSError if directory ...
[ "Makes", "directory", "for", "the", "given", "directory", "path", "with", "default", "permissions", ".", "If", "the", "directory", "already", "exists", "it", "is", "treated", "as", "success", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/support.py#L117-L136
[ "def", "makeDirectoryFromAbsolutePath", "(", "absDirPath", ")", ":", "assert", "os", ".", "path", ".", "isabs", "(", "absDirPath", ")", "try", ":", "os", ".", "makedirs", "(", "absDirPath", ")", "except", "OSError", ",", "e", ":", "if", "e", ".", "errno"...
5922fafffdccc8812e72b3324965ad2f7d4bbdad
valid
ConfigurationBase._readConfigFile
Parse the given XML file and return a dict describing the file. Parameters: ---------------------------------------------------------------- filename: name of XML file to parse (no path) path: path of the XML file. If None, then use the standard configuration search path. re...
src/nupic/swarming/hypersearch/support.py
def _readConfigFile(cls, filename, path=None): """ Parse the given XML file and return a dict describing the file. Parameters: ---------------------------------------------------------------- filename: name of XML file to parse (no path) path: path of the XML file. If None, then use the stand...
def _readConfigFile(cls, filename, path=None): """ Parse the given XML file and return a dict describing the file. Parameters: ---------------------------------------------------------------- filename: name of XML file to parse (no path) path: path of the XML file. If None, then use the stand...
[ "Parse", "the", "given", "XML", "file", "and", "return", "a", "dict", "describing", "the", "file", "." ]
numenta/nupic
python
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/support.py#L331-L460
[ "def", "_readConfigFile", "(", "cls", ",", "filename", ",", "path", "=", "None", ")", ":", "outputProperties", "=", "dict", "(", ")", "# Get the path to the config files.", "if", "path", "is", "None", ":", "filePath", "=", "cls", ".", "findConfigFile", "(", ...
5922fafffdccc8812e72b3324965ad2f7d4bbdad