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 | _PermutationUtils.getOptimizationMetricInfo | Retrives the optimization key name and optimization function.
Parameters:
---------------------------------------------------------
searchJobParams:
Parameter for passing as the searchParams arg to
Hypersearch constructor.
retval: (optimizationMetricKey, ma... | src/nupic/swarming/permutations_runner.py | def getOptimizationMetricInfo(cls, searchJobParams):
"""Retrives the optimization key name and optimization function.
Parameters:
---------------------------------------------------------
searchJobParams:
Parameter for passing as the searchParams arg to
Hypersear... | def getOptimizationMetricInfo(cls, searchJobParams):
"""Retrives the optimization key name and optimization function.
Parameters:
---------------------------------------------------------
searchJobParams:
Parameter for passing as the searchParams arg to
Hypersear... | [
"Retrives",
"the",
"optimization",
"key",
"name",
"and",
"optimization",
"function",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/permutations_runner.py#L1838-L1858 | [
"def",
"getOptimizationMetricInfo",
"(",
"cls",
",",
"searchJobParams",
")",
":",
"if",
"searchJobParams",
"[",
"\"hsVersion\"",
"]",
"==",
"\"v2\"",
":",
"search",
"=",
"HypersearchV2",
"(",
"searchParams",
"=",
"searchJobParams",
")",
"else",
":",
"raise",
"Ru... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _NupicModelInfo.getModelDescription | Parameters:
----------------------------------------------------------------------
retval: Printable description of the model. | src/nupic/swarming/permutations_runner.py | def getModelDescription(self):
"""
Parameters:
----------------------------------------------------------------------
retval: Printable description of the model.
"""
params = self.__unwrapParams()
if "experimentName" in params:
return params["experimentName"]
else:
... | def getModelDescription(self):
"""
Parameters:
----------------------------------------------------------------------
retval: Printable description of the model.
"""
params = self.__unwrapParams()
if "experimentName" in params:
return params["experimentName"]
else:
... | [
"Parameters",
":",
"----------------------------------------------------------------------",
"retval",
":",
"Printable",
"description",
"of",
"the",
"model",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/permutations_runner.py#L2116-L2133 | [
"def",
"getModelDescription",
"(",
"self",
")",
":",
"params",
"=",
"self",
".",
"__unwrapParams",
"(",
")",
"if",
"\"experimentName\"",
"in",
"params",
":",
"return",
"params",
"[",
"\"experimentName\"",
"]",
"else",
":",
"paramSettings",
"=",
"self",
".",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _NupicModelInfo.getParamLabels | Parameters:
----------------------------------------------------------------------
retval: a dictionary of model parameter labels. For each entry
the key is the name of the parameter and the value
is the value chosen for it. | src/nupic/swarming/permutations_runner.py | def getParamLabels(self):
"""
Parameters:
----------------------------------------------------------------------
retval: a dictionary of model parameter labels. For each entry
the key is the name of the parameter and the value
is the value chosen for it.
... | def getParamLabels(self):
"""
Parameters:
----------------------------------------------------------------------
retval: a dictionary of model parameter labels. For each entry
the key is the name of the parameter and the value
is the value chosen for it.
... | [
"Parameters",
":",
"----------------------------------------------------------------------",
"retval",
":",
"a",
"dictionary",
"of",
"model",
"parameter",
"labels",
".",
"For",
"each",
"entry",
"the",
"key",
"is",
"the",
"name",
"of",
"the",
"parameter",
"and",
"the",... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/permutations_runner.py#L2158-L2183 | [
"def",
"getParamLabels",
"(",
"self",
")",
":",
"params",
"=",
"self",
".",
"__unwrapParams",
"(",
")",
"# Hypersearch v2 stores the flattened parameter settings in \"particleState\"",
"if",
"\"particleState\"",
"in",
"params",
":",
"retval",
"=",
"dict",
"(",
")",
"q... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _NupicModelInfo.__unwrapParams | Unwraps self.__rawInfo.params into the equivalent python dictionary
and caches it in self.__cachedParams. Returns the unwrapped params
Parameters:
----------------------------------------------------------------------
retval: Model params dictionary as correpsonding to the json
... | src/nupic/swarming/permutations_runner.py | def __unwrapParams(self):
"""Unwraps self.__rawInfo.params into the equivalent python dictionary
and caches it in self.__cachedParams. Returns the unwrapped params
Parameters:
----------------------------------------------------------------------
retval: Model params dictionary as correpson... | def __unwrapParams(self):
"""Unwraps self.__rawInfo.params into the equivalent python dictionary
and caches it in self.__cachedParams. Returns the unwrapped params
Parameters:
----------------------------------------------------------------------
retval: Model params dictionary as correpson... | [
"Unwraps",
"self",
".",
"__rawInfo",
".",
"params",
"into",
"the",
"equivalent",
"python",
"dictionary",
"and",
"caches",
"it",
"in",
"self",
".",
"__cachedParams",
".",
"Returns",
"the",
"unwrapped",
"params"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/permutations_runner.py#L2187-L2201 | [
"def",
"__unwrapParams",
"(",
"self",
")",
":",
"if",
"self",
".",
"__cachedParams",
"is",
"None",
":",
"self",
".",
"__cachedParams",
"=",
"json",
".",
"loads",
"(",
"self",
".",
"__rawInfo",
".",
"params",
")",
"assert",
"self",
".",
"__cachedParams",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _NupicModelInfo.getAllMetrics | Retrives a dictionary of metrics that combines all report and
optimization metrics
Parameters:
----------------------------------------------------------------------
retval: a dictionary of optimization metrics that were collected
for the model; an empty dictionary if there ... | src/nupic/swarming/permutations_runner.py | def getAllMetrics(self):
"""Retrives a dictionary of metrics that combines all report and
optimization metrics
Parameters:
----------------------------------------------------------------------
retval: a dictionary of optimization metrics that were collected
for the mode... | def getAllMetrics(self):
"""Retrives a dictionary of metrics that combines all report and
optimization metrics
Parameters:
----------------------------------------------------------------------
retval: a dictionary of optimization metrics that were collected
for the mode... | [
"Retrives",
"a",
"dictionary",
"of",
"metrics",
"that",
"combines",
"all",
"report",
"and",
"optimization",
"metrics"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/permutations_runner.py#L2227-L2238 | [
"def",
"getAllMetrics",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"getReportMetrics",
"(",
")",
"result",
".",
"update",
"(",
"self",
".",
"getOptimizationMetrics",
"(",
")",
")",
"return",
"result"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _NupicModelInfo.__unwrapResults | Unwraps self.__rawInfo.results and caches it in self.__cachedResults;
Returns the unwrapped params
Parameters:
----------------------------------------------------------------------
retval: ModelResults namedtuple instance | src/nupic/swarming/permutations_runner.py | def __unwrapResults(self):
"""Unwraps self.__rawInfo.results and caches it in self.__cachedResults;
Returns the unwrapped params
Parameters:
----------------------------------------------------------------------
retval: ModelResults namedtuple instance
"""
if self.__cachedResults is... | def __unwrapResults(self):
"""Unwraps self.__rawInfo.results and caches it in self.__cachedResults;
Returns the unwrapped params
Parameters:
----------------------------------------------------------------------
retval: ModelResults namedtuple instance
"""
if self.__cachedResults is... | [
"Unwraps",
"self",
".",
"__rawInfo",
".",
"results",
"and",
"caches",
"it",
"in",
"self",
".",
"__cachedResults",
";",
"Returns",
"the",
"unwrapped",
"params"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/permutations_runner.py#L2250-L2273 | [
"def",
"__unwrapResults",
"(",
"self",
")",
":",
"if",
"self",
".",
"__cachedResults",
"is",
"None",
":",
"if",
"self",
".",
"__rawInfo",
".",
"results",
"is",
"not",
"None",
":",
"resultList",
"=",
"json",
".",
"loads",
"(",
"self",
".",
"__rawInfo",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | Distributions.getData | Returns the next n values for the distribution as a list. | src/nupic/data/generators/distributions.py | def getData(self, n):
"""Returns the next n values for the distribution as a list."""
records = [self.getNext() for x in range(n)]
return records | def getData(self, n):
"""Returns the next n values for the distribution as a list."""
records = [self.getNext() for x in range(n)]
return records | [
"Returns",
"the",
"next",
"n",
"values",
"for",
"the",
"distribution",
"as",
"a",
"list",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/generators/distributions.py#L50-L54 | [
"def",
"getData",
"(",
"self",
",",
"n",
")",
":",
"records",
"=",
"[",
"self",
".",
"getNext",
"(",
")",
"for",
"x",
"in",
"range",
"(",
"n",
")",
"]",
"return",
"records"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | ModelTerminator.getTerminationCallbacks | Returns the periodic checks to see if the model should
continue running.
Parameters:
-----------------------------------------------------------------------
terminationFunc: The function that will be called in the model main loop
as a wrapper around this function. Must have a par... | src/nupic/swarming/hypersearch/model_terminator.py | def getTerminationCallbacks(self, terminationFunc):
""" Returns the periodic checks to see if the model should
continue running.
Parameters:
-----------------------------------------------------------------------
terminationFunc: The function that will be called in the model main loop
... | def getTerminationCallbacks(self, terminationFunc):
""" Returns the periodic checks to see if the model should
continue running.
Parameters:
-----------------------------------------------------------------------
terminationFunc: The function that will be called in the model main loop
... | [
"Returns",
"the",
"periodic",
"checks",
"to",
"see",
"if",
"the",
"model",
"should",
"continue",
"running",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/model_terminator.py#L59-L76 | [
"def",
"getTerminationCallbacks",
"(",
"self",
",",
"terminationFunc",
")",
":",
"activities",
"=",
"[",
"None",
"]",
"*",
"len",
"(",
"ModelTerminator",
".",
"_MILESTONES",
")",
"for",
"index",
",",
"(",
"iteration",
",",
"_",
")",
"in",
"enumerate",
"(",... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | groupby2 | Like itertools.groupby, with the following additions:
- Supports multiple sequences. Instead of returning (k, g), each iteration
returns (k, g0, g1, ...), with one `g` for each input sequence. The value of
each `g` is either a non-empty iterator or `None`.
- It treats the value `None` as an empty sequence.... | src/nupic/support/group_by.py | def groupby2(*args):
""" Like itertools.groupby, with the following additions:
- Supports multiple sequences. Instead of returning (k, g), each iteration
returns (k, g0, g1, ...), with one `g` for each input sequence. The value of
each `g` is either a non-empty iterator or `None`.
- It treats the value `... | def groupby2(*args):
""" Like itertools.groupby, with the following additions:
- Supports multiple sequences. Instead of returning (k, g), each iteration
returns (k, g0, g1, ...), with one `g` for each input sequence. The value of
each `g` is either a non-empty iterator or `None`.
- It treats the value `... | [
"Like",
"itertools",
".",
"groupby",
"with",
"the",
"following",
"additions",
":"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/support/group_by.py#L25-L96 | [
"def",
"groupby2",
"(",
"*",
"args",
")",
":",
"generatorList",
"=",
"[",
"]",
"# list of each list's (k, group) tuples",
"if",
"len",
"(",
"args",
")",
"%",
"2",
"==",
"1",
":",
"raise",
"ValueError",
"(",
"\"Must have a key function for every list.\"",
")",
"a... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | StreamReader._openStream | Open the underlying file stream
This only supports 'file://' prefixed paths.
:returns: record stream instance
:rtype: FileRecordStream | src/nupic/data/stream_reader.py | def _openStream(dataUrl,
isBlocking, # pylint: disable=W0613
maxTimeout, # pylint: disable=W0613
bookmark,
firstRecordIdx):
"""Open the underlying file stream
This only supports 'file://' prefixed paths.
:returns: record stream insta... | def _openStream(dataUrl,
isBlocking, # pylint: disable=W0613
maxTimeout, # pylint: disable=W0613
bookmark,
firstRecordIdx):
"""Open the underlying file stream
This only supports 'file://' prefixed paths.
:returns: record stream insta... | [
"Open",
"the",
"underlying",
"file",
"stream",
"This",
"only",
"supports",
"file",
":",
"//",
"prefixed",
"paths",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/stream_reader.py#L281-L298 | [
"def",
"_openStream",
"(",
"dataUrl",
",",
"isBlocking",
",",
"# pylint: disable=W0613",
"maxTimeout",
",",
"# pylint: disable=W0613",
"bookmark",
",",
"firstRecordIdx",
")",
":",
"filePath",
"=",
"dataUrl",
"[",
"len",
"(",
"FILE_PREF",
")",
":",
"]",
"if",
"no... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | StreamReader.getNextRecord | Returns combined data from all sources (values only).
:returns: None on EOF; empty sequence on timeout. | src/nupic/data/stream_reader.py | def getNextRecord(self):
""" Returns combined data from all sources (values only).
:returns: None on EOF; empty sequence on timeout.
"""
# Keep reading from the raw input till we get enough for an aggregated
# record
while True:
# Reached EOF due to lastRow constraint?
if self._... | def getNextRecord(self):
""" Returns combined data from all sources (values only).
:returns: None on EOF; empty sequence on timeout.
"""
# Keep reading from the raw input till we get enough for an aggregated
# record
while True:
# Reached EOF due to lastRow constraint?
if self._... | [
"Returns",
"combined",
"data",
"from",
"all",
"sources",
"(",
"values",
"only",
")",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/stream_reader.py#L307-L372 | [
"def",
"getNextRecord",
"(",
"self",
")",
":",
"# Keep reading from the raw input till we get enough for an aggregated",
"# record",
"while",
"True",
":",
"# Reached EOF due to lastRow constraint?",
"if",
"self",
".",
"_sourceLastRecordIdx",
"is",
"not",
"None",
"and",
"self... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | StreamReader.getDataRowCount | Iterates through stream to calculate total records after aggregation.
This will alter the bookmark state. | src/nupic/data/stream_reader.py | def getDataRowCount(self):
"""
Iterates through stream to calculate total records after aggregation.
This will alter the bookmark state.
"""
inputRowCountAfterAggregation = 0
while True:
record = self.getNextRecord()
if record is None:
return inputRowCountAfterAggregation
... | def getDataRowCount(self):
"""
Iterates through stream to calculate total records after aggregation.
This will alter the bookmark state.
"""
inputRowCountAfterAggregation = 0
while True:
record = self.getNextRecord()
if record is None:
return inputRowCountAfterAggregation
... | [
"Iterates",
"through",
"stream",
"to",
"calculate",
"total",
"records",
"after",
"aggregation",
".",
"This",
"will",
"alter",
"the",
"bookmark",
"state",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/stream_reader.py#L375-L388 | [
"def",
"getDataRowCount",
"(",
"self",
")",
":",
"inputRowCountAfterAggregation",
"=",
"0",
"while",
"True",
":",
"record",
"=",
"self",
".",
"getNextRecord",
"(",
")",
"if",
"record",
"is",
"None",
":",
"return",
"inputRowCountAfterAggregation",
"inputRowCountAft... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | StreamReader.getStats | TODO: This method needs to be enhanced to get the stats on the *aggregated*
records.
:returns: stats (like min and max values of the fields). | src/nupic/data/stream_reader.py | def getStats(self):
"""
TODO: This method needs to be enhanced to get the stats on the *aggregated*
records.
:returns: stats (like min and max values of the fields).
"""
# The record store returns a dict of stats, each value in this dict is
# a list with one item per field of the record s... | def getStats(self):
"""
TODO: This method needs to be enhanced to get the stats on the *aggregated*
records.
:returns: stats (like min and max values of the fields).
"""
# The record store returns a dict of stats, each value in this dict is
# a list with one item per field of the record s... | [
"TODO",
":",
"This",
"method",
"needs",
"to",
"be",
"enhanced",
"to",
"get",
"the",
"stats",
"on",
"the",
"*",
"aggregated",
"*",
"records",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/stream_reader.py#L468-L493 | [
"def",
"getStats",
"(",
"self",
")",
":",
"# The record store returns a dict of stats, each value in this dict is",
"# a list with one item per field of the record store",
"# {",
"# 'min' : [f1_min, f2_min, f3_min],",
"# 'max' : [f1_max, f2_max, f3_max]",
"# ... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PatternMachine.get | Return a pattern for a number.
@param number (int) Number of pattern
@return (set) Indices of on bits | src/nupic/data/generators/pattern_machine.py | def get(self, number):
"""
Return a pattern for a number.
@param number (int) Number of pattern
@return (set) Indices of on bits
"""
if not number in self._patterns:
raise IndexError("Invalid number")
return self._patterns[number] | def get(self, number):
"""
Return a pattern for a number.
@param number (int) Number of pattern
@return (set) Indices of on bits
"""
if not number in self._patterns:
raise IndexError("Invalid number")
return self._patterns[number] | [
"Return",
"a",
"pattern",
"for",
"a",
"number",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/generators/pattern_machine.py#L61-L72 | [
"def",
"get",
"(",
"self",
",",
"number",
")",
":",
"if",
"not",
"number",
"in",
"self",
".",
"_patterns",
":",
"raise",
"IndexError",
"(",
"\"Invalid number\"",
")",
"return",
"self",
".",
"_patterns",
"[",
"number",
"]"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PatternMachine.addNoise | Add noise to pattern.
@param bits (set) Indices of on bits
@param amount (float) Probability of switching an on bit with a random bit
@return (set) Indices of on bits in noisy pattern | src/nupic/data/generators/pattern_machine.py | def addNoise(self, bits, amount):
"""
Add noise to pattern.
@param bits (set) Indices of on bits
@param amount (float) Probability of switching an on bit with a random bit
@return (set) Indices of on bits in noisy pattern
"""
newBits = set()
for bit in bits:
if self._random.... | def addNoise(self, bits, amount):
"""
Add noise to pattern.
@param bits (set) Indices of on bits
@param amount (float) Probability of switching an on bit with a random bit
@return (set) Indices of on bits in noisy pattern
"""
newBits = set()
for bit in bits:
if self._random.... | [
"Add",
"noise",
"to",
"pattern",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/generators/pattern_machine.py#L75-L92 | [
"def",
"addNoise",
"(",
"self",
",",
"bits",
",",
"amount",
")",
":",
"newBits",
"=",
"set",
"(",
")",
"for",
"bit",
"in",
"bits",
":",
"if",
"self",
".",
"_random",
".",
"getReal64",
"(",
")",
"<",
"amount",
":",
"newBits",
".",
"add",
"(",
"sel... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PatternMachine.numbersForBit | Return the set of pattern numbers that match a bit.
@param bit (int) Index of bit
@return (set) Indices of numbers | src/nupic/data/generators/pattern_machine.py | def numbersForBit(self, bit):
"""
Return the set of pattern numbers that match a bit.
@param bit (int) Index of bit
@return (set) Indices of numbers
"""
if bit >= self._n:
raise IndexError("Invalid bit")
numbers = set()
for index, pattern in self._patterns.iteritems():
if... | def numbersForBit(self, bit):
"""
Return the set of pattern numbers that match a bit.
@param bit (int) Index of bit
@return (set) Indices of numbers
"""
if bit >= self._n:
raise IndexError("Invalid bit")
numbers = set()
for index, pattern in self._patterns.iteritems():
if... | [
"Return",
"the",
"set",
"of",
"pattern",
"numbers",
"that",
"match",
"a",
"bit",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/generators/pattern_machine.py#L95-L112 | [
"def",
"numbersForBit",
"(",
"self",
",",
"bit",
")",
":",
"if",
"bit",
">=",
"self",
".",
"_n",
":",
"raise",
"IndexError",
"(",
"\"Invalid bit\"",
")",
"numbers",
"=",
"set",
"(",
")",
"for",
"index",
",",
"pattern",
"in",
"self",
".",
"_patterns",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PatternMachine.numberMapForBits | Return a map from number to matching on bits,
for all numbers that match a set of bits.
@param bits (set) Indices of bits
@return (dict) Mapping from number => on bits. | src/nupic/data/generators/pattern_machine.py | def numberMapForBits(self, bits):
"""
Return a map from number to matching on bits,
for all numbers that match a set of bits.
@param bits (set) Indices of bits
@return (dict) Mapping from number => on bits.
"""
numberMap = dict()
for bit in bits:
numbers = self.numbersForBit(bit... | def numberMapForBits(self, bits):
"""
Return a map from number to matching on bits,
for all numbers that match a set of bits.
@param bits (set) Indices of bits
@return (dict) Mapping from number => on bits.
"""
numberMap = dict()
for bit in bits:
numbers = self.numbersForBit(bit... | [
"Return",
"a",
"map",
"from",
"number",
"to",
"matching",
"on",
"bits",
"for",
"all",
"numbers",
"that",
"match",
"a",
"set",
"of",
"bits",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/generators/pattern_machine.py#L115-L135 | [
"def",
"numberMapForBits",
"(",
"self",
",",
"bits",
")",
":",
"numberMap",
"=",
"dict",
"(",
")",
"for",
"bit",
"in",
"bits",
":",
"numbers",
"=",
"self",
".",
"numbersForBit",
"(",
"bit",
")",
"for",
"number",
"in",
"numbers",
":",
"if",
"not",
"nu... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PatternMachine.prettyPrintPattern | Pretty print a pattern.
@param bits (set) Indices of on bits
@param verbosity (int) Verbosity level
@return (string) Pretty-printed text | src/nupic/data/generators/pattern_machine.py | def prettyPrintPattern(self, bits, verbosity=1):
"""
Pretty print a pattern.
@param bits (set) Indices of on bits
@param verbosity (int) Verbosity level
@return (string) Pretty-printed text
"""
numberMap = self.numberMapForBits(bits)
text = ""
numberList = []
numberItems ... | def prettyPrintPattern(self, bits, verbosity=1):
"""
Pretty print a pattern.
@param bits (set) Indices of on bits
@param verbosity (int) Verbosity level
@return (string) Pretty-printed text
"""
numberMap = self.numberMapForBits(bits)
text = ""
numberList = []
numberItems ... | [
"Pretty",
"print",
"a",
"pattern",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/generators/pattern_machine.py#L138-L169 | [
"def",
"prettyPrintPattern",
"(",
"self",
",",
"bits",
",",
"verbosity",
"=",
"1",
")",
":",
"numberMap",
"=",
"self",
".",
"numberMapForBits",
"(",
"bits",
")",
"text",
"=",
"\"\"",
"numberList",
"=",
"[",
"]",
"numberItems",
"=",
"sorted",
"(",
"number... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PatternMachine._generate | Generates set of random patterns. | src/nupic/data/generators/pattern_machine.py | def _generate(self):
"""
Generates set of random patterns.
"""
candidates = np.array(range(self._n), np.uint32)
for i in xrange(self._num):
self._random.shuffle(candidates)
pattern = candidates[0:self._getW()]
self._patterns[i] = set(pattern) | def _generate(self):
"""
Generates set of random patterns.
"""
candidates = np.array(range(self._n), np.uint32)
for i in xrange(self._num):
self._random.shuffle(candidates)
pattern = candidates[0:self._getW()]
self._patterns[i] = set(pattern) | [
"Generates",
"set",
"of",
"random",
"patterns",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/generators/pattern_machine.py#L172-L180 | [
"def",
"_generate",
"(",
"self",
")",
":",
"candidates",
"=",
"np",
".",
"array",
"(",
"range",
"(",
"self",
".",
"_n",
")",
",",
"np",
".",
"uint32",
")",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"_num",
")",
":",
"self",
".",
"_random",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PatternMachine._getW | Gets a value of `w` for use in generating a pattern. | src/nupic/data/generators/pattern_machine.py | def _getW(self):
"""
Gets a value of `w` for use in generating a pattern.
"""
w = self._w
if type(w) is list:
return w[self._random.getUInt32(len(w))]
else:
return w | def _getW(self):
"""
Gets a value of `w` for use in generating a pattern.
"""
w = self._w
if type(w) is list:
return w[self._random.getUInt32(len(w))]
else:
return w | [
"Gets",
"a",
"value",
"of",
"w",
"for",
"use",
"in",
"generating",
"a",
"pattern",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/generators/pattern_machine.py#L183-L192 | [
"def",
"_getW",
"(",
"self",
")",
":",
"w",
"=",
"self",
".",
"_w",
"if",
"type",
"(",
"w",
")",
"is",
"list",
":",
"return",
"w",
"[",
"self",
".",
"_random",
".",
"getUInt32",
"(",
"len",
"(",
"w",
")",
")",
"]",
"else",
":",
"return",
"w"
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | ConsecutivePatternMachine._generate | Generates set of consecutive patterns. | src/nupic/data/generators/pattern_machine.py | def _generate(self):
"""
Generates set of consecutive patterns.
"""
n = self._n
w = self._w
assert type(w) is int, "List for w not supported"
for i in xrange(n / w):
pattern = set(xrange(i * w, (i+1) * w))
self._patterns[i] = pattern | def _generate(self):
"""
Generates set of consecutive patterns.
"""
n = self._n
w = self._w
assert type(w) is int, "List for w not supported"
for i in xrange(n / w):
pattern = set(xrange(i * w, (i+1) * w))
self._patterns[i] = pattern | [
"Generates",
"set",
"of",
"consecutive",
"patterns",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/generators/pattern_machine.py#L202-L213 | [
"def",
"_generate",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"_n",
"w",
"=",
"self",
".",
"_w",
"assert",
"type",
"(",
"w",
")",
"is",
"int",
",",
"\"List for w not supported\"",
"for",
"i",
"in",
"xrange",
"(",
"n",
"/",
"w",
")",
":",
"pat... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SDRClassifier.compute | Process one input sample.
This method is called by outer loop code outside the nupic-engine. We
use this instead of the nupic engine compute() because our inputs and
outputs aren't fixed size vectors of reals.
:param recordNum: Record number of this input pattern. Record numbers
normally increa... | src/nupic/algorithms/sdr_classifier.py | def compute(self, recordNum, patternNZ, classification, learn, infer):
"""
Process one input sample.
This method is called by outer loop code outside the nupic-engine. We
use this instead of the nupic engine compute() because our inputs and
outputs aren't fixed size vectors of reals.
:param r... | def compute(self, recordNum, patternNZ, classification, learn, infer):
"""
Process one input sample.
This method is called by outer loop code outside the nupic-engine. We
use this instead of the nupic engine compute() because our inputs and
outputs aren't fixed size vectors of reals.
:param r... | [
"Process",
"one",
"input",
"sample",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/sdr_classifier.py#L162-L315 | [
"def",
"compute",
"(",
"self",
",",
"recordNum",
",",
"patternNZ",
",",
"classification",
",",
"learn",
",",
"infer",
")",
":",
"if",
"self",
".",
"verbosity",
">=",
"1",
":",
"print",
"\" learn:\"",
",",
"learn",
"print",
"\" recordNum:\"",
",",
"record... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SDRClassifier.infer | Return the inference value from one input sample. The actual
learning happens in compute().
:param patternNZ: list of the active indices from the output below
:param classification: dict of the classification information:
bucketIdx: index of the encoder bucket
actVal... | src/nupic/algorithms/sdr_classifier.py | def infer(self, patternNZ, actValueList):
"""
Return the inference value from one input sample. The actual
learning happens in compute().
:param patternNZ: list of the active indices from the output below
:param classification: dict of the classification information:
bucketIdx: ... | def infer(self, patternNZ, actValueList):
"""
Return the inference value from one input sample. The actual
learning happens in compute().
:param patternNZ: list of the active indices from the output below
:param classification: dict of the classification information:
bucketIdx: ... | [
"Return",
"the",
"inference",
"value",
"from",
"one",
"input",
"sample",
".",
"The",
"actual",
"learning",
"happens",
"in",
"compute",
"()",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/sdr_classifier.py#L319-L362 | [
"def",
"infer",
"(",
"self",
",",
"patternNZ",
",",
"actValueList",
")",
":",
"# Return value dict. For buckets which we don't have an actual value",
"# for yet, just plug in any valid actual value. It doesn't matter what",
"# we use because that bucket won't have non-zero likelihood anyways... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SDRClassifier.inferSingleStep | Perform inference for a single step. Given an SDR input and a weight
matrix, return a predicted distribution.
:param patternNZ: list of the active indices from the output below
:param weightMatrix: numpy array of the weight matrix
:return: numpy array of the predicted class label distribution | src/nupic/algorithms/sdr_classifier.py | def inferSingleStep(self, patternNZ, weightMatrix):
"""
Perform inference for a single step. Given an SDR input and a weight
matrix, return a predicted distribution.
:param patternNZ: list of the active indices from the output below
:param weightMatrix: numpy array of the weight matrix
:return:... | def inferSingleStep(self, patternNZ, weightMatrix):
"""
Perform inference for a single step. Given an SDR input and a weight
matrix, return a predicted distribution.
:param patternNZ: list of the active indices from the output below
:param weightMatrix: numpy array of the weight matrix
:return:... | [
"Perform",
"inference",
"for",
"a",
"single",
"step",
".",
"Given",
"an",
"SDR",
"input",
"and",
"a",
"weight",
"matrix",
"return",
"a",
"predicted",
"distribution",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/sdr_classifier.py#L365-L380 | [
"def",
"inferSingleStep",
"(",
"self",
",",
"patternNZ",
",",
"weightMatrix",
")",
":",
"outputActivation",
"=",
"weightMatrix",
"[",
"patternNZ",
"]",
".",
"sum",
"(",
"axis",
"=",
"0",
")",
"# softmax normalization",
"outputActivation",
"=",
"outputActivation",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SDRClassifier._calculateError | Calculate error signal
:param bucketIdxList: list of encoder buckets
:return: dict containing error. The key is the number of steps
The value is a numpy array of error at the output layer | src/nupic/algorithms/sdr_classifier.py | def _calculateError(self, recordNum, bucketIdxList):
"""
Calculate error signal
:param bucketIdxList: list of encoder buckets
:return: dict containing error. The key is the number of steps
The value is a numpy array of error at the output layer
"""
error = dict()
targetDist = ... | def _calculateError(self, recordNum, bucketIdxList):
"""
Calculate error signal
:param bucketIdxList: list of encoder buckets
:return: dict containing error. The key is the number of steps
The value is a numpy array of error at the output layer
"""
error = dict()
targetDist = ... | [
"Calculate",
"error",
"signal"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/sdr_classifier.py#L478-L500 | [
"def",
"_calculateError",
"(",
"self",
",",
"recordNum",
",",
"bucketIdxList",
")",
":",
"error",
"=",
"dict",
"(",
")",
"targetDist",
"=",
"numpy",
".",
"zeros",
"(",
"self",
".",
"_maxBucketIdx",
"+",
"1",
")",
"numCategories",
"=",
"len",
"(",
"bucket... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | sort | Sort a potentially big file
filename - the input file (standard File format)
key - a list of field names to sort by
outputFile - the name of the output file
fields - a list of fields that should be included (all fields if None)
watermark - when available memory goes bellow the watermark create a new chunk
... | src/nupic/data/sorter.py | def sort(filename, key, outputFile, fields=None, watermark=1024 * 1024 * 100):
"""Sort a potentially big file
filename - the input file (standard File format)
key - a list of field names to sort by
outputFile - the name of the output file
fields - a list of fields that should be included (all fields if None)... | def sort(filename, key, outputFile, fields=None, watermark=1024 * 1024 * 100):
"""Sort a potentially big file
filename - the input file (standard File format)
key - a list of field names to sort by
outputFile - the name of the output file
fields - a list of fields that should be included (all fields if None)... | [
"Sort",
"a",
"potentially",
"big",
"file"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/sorter.py#L41-L113 | [
"def",
"sort",
"(",
"filename",
",",
"key",
",",
"outputFile",
",",
"fields",
"=",
"None",
",",
"watermark",
"=",
"1024",
"*",
"1024",
"*",
"100",
")",
":",
"if",
"fields",
"is",
"not",
"None",
":",
"assert",
"set",
"(",
"key",
")",
".",
"issubset"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _sortChunk | Sort in memory chunk of records
records - a list of records read from the original dataset
key - a list of indices to sort the records by
chunkIndex - the index of the current chunk
The records contain only the fields requested by the user.
_sortChunk() will write the sorted records to a standard File
na... | src/nupic/data/sorter.py | def _sortChunk(records, key, chunkIndex, fields):
"""Sort in memory chunk of records
records - a list of records read from the original dataset
key - a list of indices to sort the records by
chunkIndex - the index of the current chunk
The records contain only the fields requested by the user.
_sortChunk(... | def _sortChunk(records, key, chunkIndex, fields):
"""Sort in memory chunk of records
records - a list of records read from the original dataset
key - a list of indices to sort the records by
chunkIndex - the index of the current chunk
The records contain only the fields requested by the user.
_sortChunk(... | [
"Sort",
"in",
"memory",
"chunk",
"of",
"records"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/sorter.py#L115-L143 | [
"def",
"_sortChunk",
"(",
"records",
",",
"key",
",",
"chunkIndex",
",",
"fields",
")",
":",
"title",
"(",
"additional",
"=",
"'(key=%s, chunkIndex=%d)'",
"%",
"(",
"str",
"(",
"key",
")",
",",
"chunkIndex",
")",
")",
"assert",
"len",
"(",
"records",
")"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _mergeFiles | Merge sorted chunk files into a sorted output file
chunkCount - the number of available chunk files
outputFile the name of the sorted output file
_mergeFiles() | src/nupic/data/sorter.py | def _mergeFiles(key, chunkCount, outputFile, fields):
"""Merge sorted chunk files into a sorted output file
chunkCount - the number of available chunk files
outputFile the name of the sorted output file
_mergeFiles()
"""
title()
# Open all chun files
files = [FileRecordStream('chunk_%d.csv' % i) for... | def _mergeFiles(key, chunkCount, outputFile, fields):
"""Merge sorted chunk files into a sorted output file
chunkCount - the number of available chunk files
outputFile the name of the sorted output file
_mergeFiles()
"""
title()
# Open all chun files
files = [FileRecordStream('chunk_%d.csv' % i) for... | [
"Merge",
"sorted",
"chunk",
"files",
"into",
"a",
"sorted",
"output",
"file"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/sorter.py#L145-L185 | [
"def",
"_mergeFiles",
"(",
"key",
",",
"chunkCount",
",",
"outputFile",
",",
"fields",
")",
":",
"title",
"(",
")",
"# Open all chun files",
"files",
"=",
"[",
"FileRecordStream",
"(",
"'chunk_%d.csv'",
"%",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"chunk... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | TemporalMemoryShim.compute | Feeds input record through TM, performing inference and learning.
Updates member variables with new state.
@param activeColumns (set) Indices of active columns in `t` | src/nupic/algorithms/temporal_memory_shim.py | def compute(self, activeColumns, learn=True):
"""
Feeds input record through TM, performing inference and learning.
Updates member variables with new state.
@param activeColumns (set) Indices of active columns in `t`
"""
bottomUpInput = numpy.zeros(self.numberOfCols, dtype=dtype)
bottomUpIn... | def compute(self, activeColumns, learn=True):
"""
Feeds input record through TM, performing inference and learning.
Updates member variables with new state.
@param activeColumns (set) Indices of active columns in `t`
"""
bottomUpInput = numpy.zeros(self.numberOfCols, dtype=dtype)
bottomUpIn... | [
"Feeds",
"input",
"record",
"through",
"TM",
"performing",
"inference",
"and",
"learning",
".",
"Updates",
"member",
"variables",
"with",
"new",
"state",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/temporal_memory_shim.py#L89-L103 | [
"def",
"compute",
"(",
"self",
",",
"activeColumns",
",",
"learn",
"=",
"True",
")",
":",
"bottomUpInput",
"=",
"numpy",
".",
"zeros",
"(",
"self",
".",
"numberOfCols",
",",
"dtype",
"=",
"dtype",
")",
"bottomUpInput",
"[",
"list",
"(",
"activeColumns",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | TemporalMemoryShim.read | Deserialize from proto instance.
:param proto: (TemporalMemoryShimProto) the proto instance to read from | src/nupic/algorithms/temporal_memory_shim.py | def read(cls, proto):
"""Deserialize from proto instance.
:param proto: (TemporalMemoryShimProto) the proto instance to read from
"""
tm = super(TemporalMemoryShim, cls).read(proto.baseTM)
tm.predictiveCells = set(proto.predictedState)
tm.connections = Connections.read(proto.conncetions) | def read(cls, proto):
"""Deserialize from proto instance.
:param proto: (TemporalMemoryShimProto) the proto instance to read from
"""
tm = super(TemporalMemoryShim, cls).read(proto.baseTM)
tm.predictiveCells = set(proto.predictedState)
tm.connections = Connections.read(proto.conncetions) | [
"Deserialize",
"from",
"proto",
"instance",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/temporal_memory_shim.py#L112-L119 | [
"def",
"read",
"(",
"cls",
",",
"proto",
")",
":",
"tm",
"=",
"super",
"(",
"TemporalMemoryShim",
",",
"cls",
")",
".",
"read",
"(",
"proto",
".",
"baseTM",
")",
"tm",
".",
"predictiveCells",
"=",
"set",
"(",
"proto",
".",
"predictedState",
")",
"tm"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | TemporalMemoryShim.write | Populate serialization proto instance.
:param proto: (TemporalMemoryShimProto) the proto instance to populate | src/nupic/algorithms/temporal_memory_shim.py | def write(self, proto):
"""Populate serialization proto instance.
:param proto: (TemporalMemoryShimProto) the proto instance to populate
"""
super(TemporalMemoryShim, self).write(proto.baseTM)
proto.connections.write(self.connections)
proto.predictiveCells = self.predictiveCells | def write(self, proto):
"""Populate serialization proto instance.
:param proto: (TemporalMemoryShimProto) the proto instance to populate
"""
super(TemporalMemoryShim, self).write(proto.baseTM)
proto.connections.write(self.connections)
proto.predictiveCells = self.predictiveCells | [
"Populate",
"serialization",
"proto",
"instance",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/temporal_memory_shim.py#L122-L129 | [
"def",
"write",
"(",
"self",
",",
"proto",
")",
":",
"super",
"(",
"TemporalMemoryShim",
",",
"self",
")",
".",
"write",
"(",
"proto",
".",
"baseTM",
")",
"proto",
".",
"connections",
".",
"write",
"(",
"self",
".",
"connections",
")",
"proto",
".",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | ConsolePrinterMixin.cPrint | Print a message to the console.
Prints only if level <= self.consolePrinterVerbosity
Printing with level 0 is equivalent to using a print statement,
and should normally be avoided.
:param level: (int) indicating the urgency of the message with
lower values meaning more urgent (messages at l... | src/nupic/support/console_printer.py | def cPrint(self, level, message, *args, **kw):
"""Print a message to the console.
Prints only if level <= self.consolePrinterVerbosity
Printing with level 0 is equivalent to using a print statement,
and should normally be avoided.
:param level: (int) indicating the urgency of the message with
... | def cPrint(self, level, message, *args, **kw):
"""Print a message to the console.
Prints only if level <= self.consolePrinterVerbosity
Printing with level 0 is equivalent to using a print statement,
and should normally be avoided.
:param level: (int) indicating the urgency of the message with
... | [
"Print",
"a",
"message",
"to",
"the",
"console",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/support/console_printer.py#L52-L90 | [
"def",
"cPrint",
"(",
"self",
",",
"level",
",",
"message",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"level",
">",
"self",
".",
"consolePrinterVerbosity",
":",
"return",
"if",
"len",
"(",
"kw",
")",
">",
"1",
":",
"raise",
"KeyError",... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | profileTM | profiling performance of TemporalMemory (TM)
using the python cProfile module and ordered by cumulative time,
see how to run on command-line above.
@param tmClass implementation of TM (cpp, py, ..)
@param tmDim number of columns in TM
@param nRuns number of calls of the profiled code (epochs) | scripts/profiling/tm_profile.py | def profileTM(tmClass, tmDim, nRuns):
"""
profiling performance of TemporalMemory (TM)
using the python cProfile module and ordered by cumulative time,
see how to run on command-line above.
@param tmClass implementation of TM (cpp, py, ..)
@param tmDim number of columns in TM
@param nRuns number of calls... | def profileTM(tmClass, tmDim, nRuns):
"""
profiling performance of TemporalMemory (TM)
using the python cProfile module and ordered by cumulative time,
see how to run on command-line above.
@param tmClass implementation of TM (cpp, py, ..)
@param tmDim number of columns in TM
@param nRuns number of calls... | [
"profiling",
"performance",
"of",
"TemporalMemory",
"(",
"TM",
")",
"using",
"the",
"python",
"cProfile",
"module",
"and",
"ordered",
"by",
"cumulative",
"time",
"see",
"how",
"to",
"run",
"on",
"command",
"-",
"line",
"above",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/scripts/profiling/tm_profile.py#L31-L54 | [
"def",
"profileTM",
"(",
"tmClass",
",",
"tmDim",
",",
"nRuns",
")",
":",
"# create TM instance to measure",
"tm",
"=",
"tmClass",
"(",
"numberOfCols",
"=",
"tmDim",
")",
"# generate input data",
"data",
"=",
"numpy",
".",
"random",
".",
"randint",
"(",
"0",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | runPermutations | The main function of the RunPermutations utility.
This utility will automatically generate and run multiple prediction framework
experiments that are permutations of a base experiment via the Grok engine.
For example, if you have an experiment that you want to test with 3 possible
values of variable A and 2 pos... | scripts/run_swarm.py | def runPermutations(args):
"""
The main function of the RunPermutations utility.
This utility will automatically generate and run multiple prediction framework
experiments that are permutations of a base experiment via the Grok engine.
For example, if you have an experiment that you want to test with 3 possib... | def runPermutations(args):
"""
The main function of the RunPermutations utility.
This utility will automatically generate and run multiple prediction framework
experiments that are permutations of a base experiment via the Grok engine.
For example, if you have an experiment that you want to test with 3 possib... | [
"The",
"main",
"function",
"of",
"the",
"RunPermutations",
"utility",
".",
"This",
"utility",
"will",
"automatically",
"generate",
"and",
"run",
"multiple",
"prediction",
"framework",
"experiments",
"that",
"are",
"permutations",
"of",
"a",
"base",
"experiment",
"... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/scripts/run_swarm.py#L35-L184 | [
"def",
"runPermutations",
"(",
"args",
")",
":",
"helpString",
"=",
"(",
"\"\\n\\n%prog [options] permutationsScript\\n\"",
"\"%prog [options] expDescription.json\\n\\n\"",
"\"This script runs permutations of an experiment via Grok engine, as \"",
"\"defined in a\\npermutations.py script or ... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _generateCategory | Generate a simple dataset. This contains a bunch of non-overlapping
sequences.
Parameters:
----------------------------------------------------
filename: name of the file to produce, including extension. It will
be created in a 'datasets' sub-directory within the
d... | examples/opf/experiments/classification/makeDatasets.py | def _generateCategory(filename="simple.csv", numSequences=2, elementsPerSeq=1,
numRepeats=10, resets=False):
""" Generate a simple dataset. This contains a bunch of non-overlapping
sequences.
Parameters:
----------------------------------------------------
filename: name of the ... | def _generateCategory(filename="simple.csv", numSequences=2, elementsPerSeq=1,
numRepeats=10, resets=False):
""" Generate a simple dataset. This contains a bunch of non-overlapping
sequences.
Parameters:
----------------------------------------------------
filename: name of the ... | [
"Generate",
"a",
"simple",
"dataset",
".",
"This",
"contains",
"a",
"bunch",
"of",
"non",
"-",
"overlapping",
"sequences",
".",
"Parameters",
":",
"----------------------------------------------------",
"filename",
":",
"name",
"of",
"the",
"file",
"to",
"produce",
... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/opf/experiments/classification/makeDatasets.py#L36-L79 | [
"def",
"_generateCategory",
"(",
"filename",
"=",
"\"simple.csv\"",
",",
"numSequences",
"=",
"2",
",",
"elementsPerSeq",
"=",
"1",
",",
"numRepeats",
"=",
"10",
",",
"resets",
"=",
"False",
")",
":",
"# Create the output file",
"scriptDir",
"=",
"os",
".",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | GeospatialCoordinateEncoder.encodeIntoArray | See `nupic.encoders.base.Encoder` for more information.
:param: inputData (tuple) Contains speed (float), longitude (float),
latitude (float), altitude (float)
:param: output (numpy.array) Stores encoded SDR in this numpy array | src/nupic/encoders/geospatial_coordinate.py | def encodeIntoArray(self, inputData, output):
"""
See `nupic.encoders.base.Encoder` for more information.
:param: inputData (tuple) Contains speed (float), longitude (float),
latitude (float), altitude (float)
:param: output (numpy.array) Stores encoded SDR in this numpy ar... | def encodeIntoArray(self, inputData, output):
"""
See `nupic.encoders.base.Encoder` for more information.
:param: inputData (tuple) Contains speed (float), longitude (float),
latitude (float), altitude (float)
:param: output (numpy.array) Stores encoded SDR in this numpy ar... | [
"See",
"nupic",
".",
"encoders",
".",
"base",
".",
"Encoder",
"for",
"more",
"information",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/geospatial_coordinate.py#L82-L98 | [
"def",
"encodeIntoArray",
"(",
"self",
",",
"inputData",
",",
"output",
")",
":",
"altitude",
"=",
"None",
"if",
"len",
"(",
"inputData",
")",
"==",
"4",
":",
"(",
"speed",
",",
"longitude",
",",
"latitude",
",",
"altitude",
")",
"=",
"inputData",
"els... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | GeospatialCoordinateEncoder.coordinateForPosition | Returns coordinate for given GPS position.
:param: longitude (float) Longitude of position
:param: latitude (float) Latitude of position
:param: altitude (float) Altitude of position
:returns: (numpy.array) Coordinate that the given GPS position
maps to | src/nupic/encoders/geospatial_coordinate.py | def coordinateForPosition(self, longitude, latitude, altitude=None):
"""
Returns coordinate for given GPS position.
:param: longitude (float) Longitude of position
:param: latitude (float) Latitude of position
:param: altitude (float) Altitude of position
:returns: (numpy.array) Coordinate that... | def coordinateForPosition(self, longitude, latitude, altitude=None):
"""
Returns coordinate for given GPS position.
:param: longitude (float) Longitude of position
:param: latitude (float) Latitude of position
:param: altitude (float) Altitude of position
:returns: (numpy.array) Coordinate that... | [
"Returns",
"coordinate",
"for",
"given",
"GPS",
"position",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/geospatial_coordinate.py#L101-L118 | [
"def",
"coordinateForPosition",
"(",
"self",
",",
"longitude",
",",
"latitude",
",",
"altitude",
"=",
"None",
")",
":",
"coords",
"=",
"PROJ",
"(",
"longitude",
",",
"latitude",
")",
"if",
"altitude",
"is",
"not",
"None",
":",
"coords",
"=",
"transform",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | GeospatialCoordinateEncoder.radiusForSpeed | Returns radius for given speed.
Tries to get the encodings of consecutive readings to be
adjacent with some overlap.
:param: speed (float) Speed (in meters per second)
:returns: (int) Radius for given speed | src/nupic/encoders/geospatial_coordinate.py | def radiusForSpeed(self, speed):
"""
Returns radius for given speed.
Tries to get the encodings of consecutive readings to be
adjacent with some overlap.
:param: speed (float) Speed (in meters per second)
:returns: (int) Radius for given speed
"""
overlap = 1.5
coordinatesPerTimest... | def radiusForSpeed(self, speed):
"""
Returns radius for given speed.
Tries to get the encodings of consecutive readings to be
adjacent with some overlap.
:param: speed (float) Speed (in meters per second)
:returns: (int) Radius for given speed
"""
overlap = 1.5
coordinatesPerTimest... | [
"Returns",
"radius",
"for",
"given",
"speed",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/geospatial_coordinate.py#L121-L135 | [
"def",
"radiusForSpeed",
"(",
"self",
",",
"speed",
")",
":",
"overlap",
"=",
"1.5",
"coordinatesPerTimestep",
"=",
"speed",
"*",
"self",
".",
"timestep",
"/",
"self",
".",
"scale",
"radius",
"=",
"int",
"(",
"round",
"(",
"float",
"(",
"coordinatesPerTime... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | getSearch | This method returns search description. See the following file for the
schema of the dictionary this method returns:
py/nupic/swarming/exp_generator/experimentDescriptionSchema.json
The streamDef element defines the stream for this model. The schema for this
element can be found at:
py/nupicengine/cl... | examples/opf/experiments/spatial_classification/auto_generated/searchDef.py | def getSearch(rootDir):
""" This method returns search description. See the following file for the
schema of the dictionary this method returns:
py/nupic/swarming/exp_generator/experimentDescriptionSchema.json
The streamDef element defines the stream for this model. The schema for this
element can be f... | def getSearch(rootDir):
""" This method returns search description. See the following file for the
schema of the dictionary this method returns:
py/nupic/swarming/exp_generator/experimentDescriptionSchema.json
The streamDef element defines the stream for this model. The schema for this
element can be f... | [
"This",
"method",
"returns",
"search",
"description",
".",
"See",
"the",
"following",
"file",
"for",
"the",
"schema",
"of",
"the",
"dictionary",
"this",
"method",
"returns",
":",
"py",
"/",
"nupic",
"/",
"swarming",
"/",
"exp_generator",
"/",
"experimentDescri... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/examples/opf/experiments/spatial_classification/auto_generated/searchDef.py#L27-L75 | [
"def",
"getSearch",
"(",
"rootDir",
")",
":",
"# Form the stream definition",
"dataPath",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"rootDir",
",",
"'datasets'",
",",
"'scalar_1.csv'",
")",
")",
"streamDef",
"=",
"di... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SparsePassThroughEncoder.encodeIntoArray | See method description in base.py | src/nupic/encoders/sparse_pass_through.py | def encodeIntoArray(self, value, output):
""" See method description in base.py """
denseInput = numpy.zeros(output.shape)
try:
denseInput[value] = 1
except IndexError:
if isinstance(value, numpy.ndarray):
raise ValueError(
"Numpy array must have integer dtype but got {}"... | def encodeIntoArray(self, value, output):
""" See method description in base.py """
denseInput = numpy.zeros(output.shape)
try:
denseInput[value] = 1
except IndexError:
if isinstance(value, numpy.ndarray):
raise ValueError(
"Numpy array must have integer dtype but got {}"... | [
"See",
"method",
"description",
"in",
"base",
".",
"py"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/sparse_pass_through.py#L71-L82 | [
"def",
"encodeIntoArray",
"(",
"self",
",",
"value",
",",
"output",
")",
":",
"denseInput",
"=",
"numpy",
".",
"zeros",
"(",
"output",
".",
"shape",
")",
"try",
":",
"denseInput",
"[",
"value",
"]",
"=",
"1",
"except",
"IndexError",
":",
"if",
"isinsta... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | Serializable.readFromFile | Read serialized object from file.
:param f: input file
:param packed: If true, will assume content is packed
:return: first-class instance initialized from proto obj | src/nupic/serializable.py | def readFromFile(cls, f, packed=True):
"""
Read serialized object from file.
:param f: input file
:param packed: If true, will assume content is packed
:return: first-class instance initialized from proto obj
"""
# Get capnproto schema from instance
schema = cls.getSchema()
# Read ... | def readFromFile(cls, f, packed=True):
"""
Read serialized object from file.
:param f: input file
:param packed: If true, will assume content is packed
:return: first-class instance initialized from proto obj
"""
# Get capnproto schema from instance
schema = cls.getSchema()
# Read ... | [
"Read",
"serialized",
"object",
"from",
"file",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/serializable.py#L81-L99 | [
"def",
"readFromFile",
"(",
"cls",
",",
"f",
",",
"packed",
"=",
"True",
")",
":",
"# Get capnproto schema from instance",
"schema",
"=",
"cls",
".",
"getSchema",
"(",
")",
"# Read from file",
"if",
"packed",
":",
"proto",
"=",
"schema",
".",
"read_packed",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | Serializable.writeToFile | Write serialized object to file.
:param f: output file
:param packed: If true, will pack contents. | src/nupic/serializable.py | def writeToFile(self, f, packed=True):
"""
Write serialized object to file.
:param f: output file
:param packed: If true, will pack contents.
"""
# Get capnproto schema from instance
schema = self.getSchema()
# Construct new message, otherwise refered to as `proto`
proto = schema.n... | def writeToFile(self, f, packed=True):
"""
Write serialized object to file.
:param f: output file
:param packed: If true, will pack contents.
"""
# Get capnproto schema from instance
schema = self.getSchema()
# Construct new message, otherwise refered to as `proto`
proto = schema.n... | [
"Write",
"serialized",
"object",
"to",
"file",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/serializable.py#L102-L122 | [
"def",
"writeToFile",
"(",
"self",
",",
"f",
",",
"packed",
"=",
"True",
")",
":",
"# Get capnproto schema from instance",
"schema",
"=",
"self",
".",
"getSchema",
"(",
")",
"# Construct new message, otherwise refered to as `proto`",
"proto",
"=",
"schema",
".",
"ne... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | TwoGramModel.read | :param proto: capnp TwoGramModelProto message reader | src/nupic/frameworks/opf/two_gram_model.py | def read(cls, proto):
"""
:param proto: capnp TwoGramModelProto message reader
"""
instance = object.__new__(cls)
super(TwoGramModel, instance).__init__(proto=proto.modelBase)
instance._logger = opf_utils.initLogger(instance)
instance._reset = proto.reset
instance._hashToValueDict = {x... | def read(cls, proto):
"""
:param proto: capnp TwoGramModelProto message reader
"""
instance = object.__new__(cls)
super(TwoGramModel, instance).__init__(proto=proto.modelBase)
instance._logger = opf_utils.initLogger(instance)
instance._reset = proto.reset
instance._hashToValueDict = {x... | [
":",
"param",
"proto",
":",
"capnp",
"TwoGramModelProto",
"message",
"reader"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/two_gram_model.py#L152-L176 | [
"def",
"read",
"(",
"cls",
",",
"proto",
")",
":",
"instance",
"=",
"object",
".",
"__new__",
"(",
"cls",
")",
"super",
"(",
"TwoGramModel",
",",
"instance",
")",
".",
"__init__",
"(",
"proto",
"=",
"proto",
".",
"modelBase",
")",
"instance",
".",
"_... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | TwoGramModel.write | :param proto: capnp TwoGramModelProto message builder | src/nupic/frameworks/opf/two_gram_model.py | def write(self, proto):
"""
:param proto: capnp TwoGramModelProto message builder
"""
super(TwoGramModel, self).writeBaseToProto(proto.modelBase)
proto.reset = self._reset
proto.learningEnabled = self._learningEnabled
proto.prevValues = self._prevValues
self._encoder.write(proto.encoder... | def write(self, proto):
"""
:param proto: capnp TwoGramModelProto message builder
"""
super(TwoGramModel, self).writeBaseToProto(proto.modelBase)
proto.reset = self._reset
proto.learningEnabled = self._learningEnabled
proto.prevValues = self._prevValues
self._encoder.write(proto.encoder... | [
":",
"param",
"proto",
":",
"capnp",
"TwoGramModelProto",
"message",
"builder"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/two_gram_model.py#L179-L204 | [
"def",
"write",
"(",
"self",
",",
"proto",
")",
":",
"super",
"(",
"TwoGramModel",
",",
"self",
")",
".",
"writeBaseToProto",
"(",
"proto",
".",
"modelBase",
")",
"proto",
".",
"reset",
"=",
"self",
".",
"_reset",
"proto",
".",
"learningEnabled",
"=",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | requireAnomalyModel | Decorator for functions that require anomaly models. | src/nupic/frameworks/opf/htm_prediction_model.py | def requireAnomalyModel(func):
"""
Decorator for functions that require anomaly models.
"""
@wraps(func)
def _decorator(self, *args, **kwargs):
if not self.getInferenceType() == InferenceType.TemporalAnomaly:
raise RuntimeError("Method required a TemporalAnomaly model.")
if self._getAnomalyClass... | def requireAnomalyModel(func):
"""
Decorator for functions that require anomaly models.
"""
@wraps(func)
def _decorator(self, *args, **kwargs):
if not self.getInferenceType() == InferenceType.TemporalAnomaly:
raise RuntimeError("Method required a TemporalAnomaly model.")
if self._getAnomalyClass... | [
"Decorator",
"for",
"functions",
"that",
"require",
"anomaly",
"models",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L70-L82 | [
"def",
"requireAnomalyModel",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"_decorator",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"getInferenceType",
"(",
")",
"==",
"InferenceType",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | HTMPredictionModel.anomalyRemoveLabels | Remove labels from the anomaly classifier within this model. Removes all
records if ``labelFilter==None``, otherwise only removes the labels equal to
``labelFilter``.
:param start: (int) index to start removing labels
:param end: (int) index to end removing labels
:param labelFilter: (string) If sp... | src/nupic/frameworks/opf/htm_prediction_model.py | def anomalyRemoveLabels(self, start, end, labelFilter):
"""
Remove labels from the anomaly classifier within this model. Removes all
records if ``labelFilter==None``, otherwise only removes the labels equal to
``labelFilter``.
:param start: (int) index to start removing labels
:param end: (int)... | def anomalyRemoveLabels(self, start, end, labelFilter):
"""
Remove labels from the anomaly classifier within this model. Removes all
records if ``labelFilter==None``, otherwise only removes the labels equal to
``labelFilter``.
:param start: (int) index to start removing labels
:param end: (int)... | [
"Remove",
"labels",
"from",
"the",
"anomaly",
"classifier",
"within",
"this",
"model",
".",
"Removes",
"all",
"records",
"if",
"labelFilter",
"==",
"None",
"otherwise",
"only",
"removes",
"the",
"labels",
"equal",
"to",
"labelFilter",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L374-L384 | [
"def",
"anomalyRemoveLabels",
"(",
"self",
",",
"start",
",",
"end",
",",
"labelFilter",
")",
":",
"self",
".",
"_getAnomalyClassifier",
"(",
")",
".",
"getSelf",
"(",
")",
".",
"removeLabels",
"(",
"start",
",",
"end",
",",
"labelFilter",
")"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | HTMPredictionModel.anomalyAddLabel | Add labels from the anomaly classifier within this model.
:param start: (int) index to start label
:param end: (int) index to end label
:param labelName: (string) name of label | src/nupic/frameworks/opf/htm_prediction_model.py | def anomalyAddLabel(self, start, end, labelName):
"""
Add labels from the anomaly classifier within this model.
:param start: (int) index to start label
:param end: (int) index to end label
:param labelName: (string) name of label
"""
self._getAnomalyClassifier().getSelf().addLabel(start, e... | def anomalyAddLabel(self, start, end, labelName):
"""
Add labels from the anomaly classifier within this model.
:param start: (int) index to start label
:param end: (int) index to end label
:param labelName: (string) name of label
"""
self._getAnomalyClassifier().getSelf().addLabel(start, e... | [
"Add",
"labels",
"from",
"the",
"anomaly",
"classifier",
"within",
"this",
"model",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L388-L396 | [
"def",
"anomalyAddLabel",
"(",
"self",
",",
"start",
",",
"end",
",",
"labelName",
")",
":",
"self",
".",
"_getAnomalyClassifier",
"(",
")",
".",
"getSelf",
"(",
")",
".",
"addLabel",
"(",
"start",
",",
"end",
",",
"labelName",
")"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | HTMPredictionModel.anomalyGetLabels | Get labels from the anomaly classifier within this model.
:param start: (int) index to start getting labels
:param end: (int) index to end getting labels | src/nupic/frameworks/opf/htm_prediction_model.py | def anomalyGetLabels(self, start, end):
"""
Get labels from the anomaly classifier within this model.
:param start: (int) index to start getting labels
:param end: (int) index to end getting labels
"""
return self._getAnomalyClassifier().getSelf().getLabels(start, end) | def anomalyGetLabels(self, start, end):
"""
Get labels from the anomaly classifier within this model.
:param start: (int) index to start getting labels
:param end: (int) index to end getting labels
"""
return self._getAnomalyClassifier().getSelf().getLabels(start, end) | [
"Get",
"labels",
"from",
"the",
"anomaly",
"classifier",
"within",
"this",
"model",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L400-L407 | [
"def",
"anomalyGetLabels",
"(",
"self",
",",
"start",
",",
"end",
")",
":",
"return",
"self",
".",
"_getAnomalyClassifier",
"(",
")",
".",
"getSelf",
"(",
")",
".",
"getLabels",
"(",
"start",
",",
"end",
")"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | HTMPredictionModel._getSensorInputRecord | inputRecord - dict containing the input to the sensor
Return a 'SensorInput' object, which represents the 'parsed'
representation of the input record | src/nupic/frameworks/opf/htm_prediction_model.py | def _getSensorInputRecord(self, inputRecord):
"""
inputRecord - dict containing the input to the sensor
Return a 'SensorInput' object, which represents the 'parsed'
representation of the input record
"""
sensor = self._getSensorRegion()
dataRow = copy.deepcopy(sensor.getSelf().getOutputValu... | def _getSensorInputRecord(self, inputRecord):
"""
inputRecord - dict containing the input to the sensor
Return a 'SensorInput' object, which represents the 'parsed'
representation of the input record
"""
sensor = self._getSensorRegion()
dataRow = copy.deepcopy(sensor.getSelf().getOutputValu... | [
"inputRecord",
"-",
"dict",
"containing",
"the",
"input",
"to",
"the",
"sensor"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L478-L496 | [
"def",
"_getSensorInputRecord",
"(",
"self",
",",
"inputRecord",
")",
":",
"sensor",
"=",
"self",
".",
"_getSensorRegion",
"(",
")",
"dataRow",
"=",
"copy",
".",
"deepcopy",
"(",
"sensor",
".",
"getSelf",
"(",
")",
".",
"getOutputValues",
"(",
"'sourceOut'",... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | HTMPredictionModel._getClassifierInputRecord | inputRecord - dict containing the input to the sensor
Return a 'ClassifierInput' object, which contains the mapped
bucket index for input Record | src/nupic/frameworks/opf/htm_prediction_model.py | def _getClassifierInputRecord(self, inputRecord):
"""
inputRecord - dict containing the input to the sensor
Return a 'ClassifierInput' object, which contains the mapped
bucket index for input Record
"""
absoluteValue = None
bucketIdx = None
if self._predictedFieldName is not None and s... | def _getClassifierInputRecord(self, inputRecord):
"""
inputRecord - dict containing the input to the sensor
Return a 'ClassifierInput' object, which contains the mapped
bucket index for input Record
"""
absoluteValue = None
bucketIdx = None
if self._predictedFieldName is not None and s... | [
"inputRecord",
"-",
"dict",
"containing",
"the",
"input",
"to",
"the",
"sensor"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L498-L513 | [
"def",
"_getClassifierInputRecord",
"(",
"self",
",",
"inputRecord",
")",
":",
"absoluteValue",
"=",
"None",
"bucketIdx",
"=",
"None",
"if",
"self",
".",
"_predictedFieldName",
"is",
"not",
"None",
"and",
"self",
".",
"_classifierInputEncoder",
"is",
"not",
"Non... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | HTMPredictionModel._anomalyCompute | Compute Anomaly score, if required | src/nupic/frameworks/opf/htm_prediction_model.py | def _anomalyCompute(self):
"""
Compute Anomaly score, if required
"""
inferenceType = self.getInferenceType()
inferences = {}
sp = self._getSPRegion()
score = None
if inferenceType == InferenceType.NontemporalAnomaly:
score = sp.getOutputData("anomalyScore")[0] #TODO move from SP ... | def _anomalyCompute(self):
"""
Compute Anomaly score, if required
"""
inferenceType = self.getInferenceType()
inferences = {}
sp = self._getSPRegion()
score = None
if inferenceType == InferenceType.NontemporalAnomaly:
score = sp.getOutputData("anomalyScore")[0] #TODO move from SP ... | [
"Compute",
"Anomaly",
"score",
"if",
"required"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L665-L709 | [
"def",
"_anomalyCompute",
"(",
"self",
")",
":",
"inferenceType",
"=",
"self",
".",
"getInferenceType",
"(",
")",
"inferences",
"=",
"{",
"}",
"sp",
"=",
"self",
".",
"_getSPRegion",
"(",
")",
"score",
"=",
"None",
"if",
"inferenceType",
"==",
"InferenceTy... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | HTMPredictionModel._handleSDRClassifierMultiStep | Handle the CLA Classifier compute logic when implementing multi-step
prediction. This is where the patternNZ is associated with one of the
other fields from the dataset 0 to N steps in the future. This method is
used by each type of network (encoder only, SP only, SP +TM) to handle the
compute logic thr... | src/nupic/frameworks/opf/htm_prediction_model.py | def _handleSDRClassifierMultiStep(self, patternNZ,
inputTSRecordIdx,
rawInput):
""" Handle the CLA Classifier compute logic when implementing multi-step
prediction. This is where the patternNZ is associated with one of the
other fields ... | def _handleSDRClassifierMultiStep(self, patternNZ,
inputTSRecordIdx,
rawInput):
""" Handle the CLA Classifier compute logic when implementing multi-step
prediction. This is where the patternNZ is associated with one of the
other fields ... | [
"Handle",
"the",
"CLA",
"Classifier",
"compute",
"logic",
"when",
"implementing",
"multi",
"-",
"step",
"prediction",
".",
"This",
"is",
"where",
"the",
"patternNZ",
"is",
"associated",
"with",
"one",
"of",
"the",
"other",
"fields",
"from",
"the",
"dataset",
... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L712-L957 | [
"def",
"_handleSDRClassifierMultiStep",
"(",
"self",
",",
"patternNZ",
",",
"inputTSRecordIdx",
",",
"rawInput",
")",
":",
"inferenceArgs",
"=",
"self",
".",
"getInferenceArgs",
"(",
")",
"predictedFieldName",
"=",
"inferenceArgs",
".",
"get",
"(",
"'predictedField'... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | HTMPredictionModel._removeUnlikelyPredictions | Remove entries with 0 likelihood or likelihood less than
minLikelihoodThreshold, but don't leave an empty dict. | src/nupic/frameworks/opf/htm_prediction_model.py | def _removeUnlikelyPredictions(cls, likelihoodsDict, minLikelihoodThreshold,
maxPredictionsPerStep):
"""Remove entries with 0 likelihood or likelihood less than
minLikelihoodThreshold, but don't leave an empty dict.
"""
maxVal = (None, None)
for (k, v) in likelihoods... | def _removeUnlikelyPredictions(cls, likelihoodsDict, minLikelihoodThreshold,
maxPredictionsPerStep):
"""Remove entries with 0 likelihood or likelihood less than
minLikelihoodThreshold, but don't leave an empty dict.
"""
maxVal = (None, None)
for (k, v) in likelihoods... | [
"Remove",
"entries",
"with",
"0",
"likelihood",
"or",
"likelihood",
"less",
"than",
"minLikelihoodThreshold",
"but",
"don",
"t",
"leave",
"an",
"empty",
"dict",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L961-L980 | [
"def",
"_removeUnlikelyPredictions",
"(",
"cls",
",",
"likelihoodsDict",
",",
"minLikelihoodThreshold",
",",
"maxPredictionsPerStep",
")",
":",
"maxVal",
"=",
"(",
"None",
",",
"None",
")",
"for",
"(",
"k",
",",
"v",
")",
"in",
"likelihoodsDict",
".",
"items",... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | HTMPredictionModel.getRuntimeStats | Only returns data for a stat called ``numRunCalls``.
:return: | src/nupic/frameworks/opf/htm_prediction_model.py | def getRuntimeStats(self):
"""
Only returns data for a stat called ``numRunCalls``.
:return:
"""
ret = {"numRunCalls" : self.__numRunCalls}
#--------------------------------------------------
# Query temporal network stats
temporalStats = dict()
if self._hasTP:
for stat in sel... | def getRuntimeStats(self):
"""
Only returns data for a stat called ``numRunCalls``.
:return:
"""
ret = {"numRunCalls" : self.__numRunCalls}
#--------------------------------------------------
# Query temporal network stats
temporalStats = dict()
if self._hasTP:
for stat in sel... | [
"Only",
"returns",
"data",
"for",
"a",
"stat",
"called",
"numRunCalls",
".",
":",
"return",
":"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L983-L1001 | [
"def",
"getRuntimeStats",
"(",
"self",
")",
":",
"ret",
"=",
"{",
"\"numRunCalls\"",
":",
"self",
".",
"__numRunCalls",
"}",
"#--------------------------------------------------",
"# Query temporal network stats",
"temporalStats",
"=",
"dict",
"(",
")",
"if",
"self",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | HTMPredictionModel._getClassifierRegion | Returns reference to the network's Classifier region | src/nupic/frameworks/opf/htm_prediction_model.py | def _getClassifierRegion(self):
"""
Returns reference to the network's Classifier region
"""
if (self._netInfo.net is not None and
"Classifier" in self._netInfo.net.regions):
return self._netInfo.net.regions["Classifier"]
else:
return None | def _getClassifierRegion(self):
"""
Returns reference to the network's Classifier region
"""
if (self._netInfo.net is not None and
"Classifier" in self._netInfo.net.regions):
return self._netInfo.net.regions["Classifier"]
else:
return None | [
"Returns",
"reference",
"to",
"the",
"network",
"s",
"Classifier",
"region"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L1059-L1067 | [
"def",
"_getClassifierRegion",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"_netInfo",
".",
"net",
"is",
"not",
"None",
"and",
"\"Classifier\"",
"in",
"self",
".",
"_netInfo",
".",
"net",
".",
"regions",
")",
":",
"return",
"self",
".",
"_netInfo",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | HTMPredictionModel.__createHTMNetwork | Create a CLA network and return it.
description: HTMPredictionModel description dictionary (TODO: define schema)
Returns: NetworkInfo instance; | src/nupic/frameworks/opf/htm_prediction_model.py | def __createHTMNetwork(self, sensorParams, spEnable, spParams, tmEnable,
tmParams, clEnable, clParams, anomalyParams):
""" Create a CLA network and return it.
description: HTMPredictionModel description dictionary (TODO: define schema)
Returns: NetworkInfo instance;
"""
... | def __createHTMNetwork(self, sensorParams, spEnable, spParams, tmEnable,
tmParams, clEnable, clParams, anomalyParams):
""" Create a CLA network and return it.
description: HTMPredictionModel description dictionary (TODO: define schema)
Returns: NetworkInfo instance;
"""
... | [
"Create",
"a",
"CLA",
"network",
"and",
"return",
"it",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L1095-L1218 | [
"def",
"__createHTMNetwork",
"(",
"self",
",",
"sensorParams",
",",
"spEnable",
",",
"spParams",
",",
"tmEnable",
",",
"tmParams",
",",
"clEnable",
",",
"clParams",
",",
"anomalyParams",
")",
":",
"#--------------------------------------------------",
"# Create the netw... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | HTMPredictionModel.write | :param proto: capnp HTMPredictionModelProto message builder | src/nupic/frameworks/opf/htm_prediction_model.py | def write(self, proto):
"""
:param proto: capnp HTMPredictionModelProto message builder
"""
super(HTMPredictionModel, self).writeBaseToProto(proto.modelBase)
proto.numRunCalls = self.__numRunCalls
proto.minLikelihoodThreshold = self._minLikelihoodThreshold
proto.maxPredictionsPerStep = self... | def write(self, proto):
"""
:param proto: capnp HTMPredictionModelProto message builder
"""
super(HTMPredictionModel, self).writeBaseToProto(proto.modelBase)
proto.numRunCalls = self.__numRunCalls
proto.minLikelihoodThreshold = self._minLikelihoodThreshold
proto.maxPredictionsPerStep = self... | [
":",
"param",
"proto",
":",
"capnp",
"HTMPredictionModelProto",
"message",
"builder"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L1328-L1354 | [
"def",
"write",
"(",
"self",
",",
"proto",
")",
":",
"super",
"(",
"HTMPredictionModel",
",",
"self",
")",
".",
"writeBaseToProto",
"(",
"proto",
".",
"modelBase",
")",
"proto",
".",
"numRunCalls",
"=",
"self",
".",
"__numRunCalls",
"proto",
".",
"minLikel... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | HTMPredictionModel.read | :param proto: capnp HTMPredictionModelProto message reader | src/nupic/frameworks/opf/htm_prediction_model.py | def read(cls, proto):
"""
:param proto: capnp HTMPredictionModelProto message reader
"""
obj = object.__new__(cls)
# model.capnp
super(HTMPredictionModel, obj).__init__(proto=proto.modelBase)
# HTMPredictionModelProto.capnp
obj._minLikelihoodThreshold = round(proto.minLikelihoodThreshol... | def read(cls, proto):
"""
:param proto: capnp HTMPredictionModelProto message reader
"""
obj = object.__new__(cls)
# model.capnp
super(HTMPredictionModel, obj).__init__(proto=proto.modelBase)
# HTMPredictionModelProto.capnp
obj._minLikelihoodThreshold = round(proto.minLikelihoodThreshol... | [
":",
"param",
"proto",
":",
"capnp",
"HTMPredictionModelProto",
"message",
"reader"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L1358-L1410 | [
"def",
"read",
"(",
"cls",
",",
"proto",
")",
":",
"obj",
"=",
"object",
".",
"__new__",
"(",
"cls",
")",
"# model.capnp",
"super",
"(",
"HTMPredictionModel",
",",
"obj",
")",
".",
"__init__",
"(",
"proto",
"=",
"proto",
".",
"modelBase",
")",
"# HTMPr... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | HTMPredictionModel._serializeExtraData | [virtual method override] This method is called during serialization
with an external directory path that can be used to bypass pickle for saving
large binary states.
extraDataDir:
Model's extra data directory path | src/nupic/frameworks/opf/htm_prediction_model.py | def _serializeExtraData(self, extraDataDir):
""" [virtual method override] This method is called during serialization
with an external directory path that can be used to bypass pickle for saving
large binary states.
extraDataDir:
Model's extra data directory path
"""
makeDirec... | def _serializeExtraData(self, extraDataDir):
""" [virtual method override] This method is called during serialization
with an external directory path that can be used to bypass pickle for saving
large binary states.
extraDataDir:
Model's extra data directory path
"""
makeDirec... | [
"[",
"virtual",
"method",
"override",
"]",
"This",
"method",
"is",
"called",
"during",
"serialization",
"with",
"an",
"external",
"directory",
"path",
"that",
"can",
"be",
"used",
"to",
"bypass",
"pickle",
"for",
"saving",
"large",
"binary",
"states",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L1413-L1433 | [
"def",
"_serializeExtraData",
"(",
"self",
",",
"extraDataDir",
")",
":",
"makeDirectoryFromAbsolutePath",
"(",
"extraDataDir",
")",
"#--------------------------------------------------",
"# Save the network",
"outputDir",
"=",
"self",
".",
"__getNetworkStateDirectory",
"(",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | HTMPredictionModel._deSerializeExtraData | [virtual method override] This method is called during deserialization
(after __setstate__) with an external directory path that can be used to
bypass pickle for loading large binary states.
extraDataDir:
Model's extra data directory path | src/nupic/frameworks/opf/htm_prediction_model.py | def _deSerializeExtraData(self, extraDataDir):
""" [virtual method override] This method is called during deserialization
(after __setstate__) with an external directory path that can be used to
bypass pickle for loading large binary states.
extraDataDir:
Model's extra data directory ... | def _deSerializeExtraData(self, extraDataDir):
""" [virtual method override] This method is called during deserialization
(after __setstate__) with an external directory path that can be used to
bypass pickle for loading large binary states.
extraDataDir:
Model's extra data directory ... | [
"[",
"virtual",
"method",
"override",
"]",
"This",
"method",
"is",
"called",
"during",
"deserialization",
"(",
"after",
"__setstate__",
")",
"with",
"an",
"external",
"directory",
"path",
"that",
"can",
"be",
"used",
"to",
"bypass",
"pickle",
"for",
"loading",... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L1436-L1514 | [
"def",
"_deSerializeExtraData",
"(",
"self",
",",
"extraDataDir",
")",
":",
"assert",
"self",
".",
"__restoringFromState",
"#--------------------------------------------------",
"# Check to make sure that our Network member wasn't restored from",
"# serialized data",
"assert",
"(",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | HTMPredictionModel._addAnomalyClassifierRegion | Attaches an 'AnomalyClassifier' region to the network. Will remove current
'AnomalyClassifier' region if it exists.
Parameters
-----------
network - network to add the AnomalyClassifier region
params - parameters to pass to the region
spEnable - True if network has an SP region
tmEnable - T... | src/nupic/frameworks/opf/htm_prediction_model.py | def _addAnomalyClassifierRegion(self, network, params, spEnable, tmEnable):
"""
Attaches an 'AnomalyClassifier' region to the network. Will remove current
'AnomalyClassifier' region if it exists.
Parameters
-----------
network - network to add the AnomalyClassifier region
params - parameter... | def _addAnomalyClassifierRegion(self, network, params, spEnable, tmEnable):
"""
Attaches an 'AnomalyClassifier' region to the network. Will remove current
'AnomalyClassifier' region if it exists.
Parameters
-----------
network - network to add the AnomalyClassifier region
params - parameter... | [
"Attaches",
"an",
"AnomalyClassifier",
"region",
"to",
"the",
"network",
".",
"Will",
"remove",
"current",
"AnomalyClassifier",
"region",
"if",
"it",
"exists",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L1517-L1570 | [
"def",
"_addAnomalyClassifierRegion",
"(",
"self",
",",
"network",
",",
"params",
",",
"spEnable",
",",
"tmEnable",
")",
":",
"allParams",
"=",
"copy",
".",
"deepcopy",
"(",
"params",
")",
"knnParams",
"=",
"dict",
"(",
"k",
"=",
"1",
",",
"distanceMethod"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | HTMPredictionModel.__getNetworkStateDirectory | extraDataDir:
Model's extra data directory path
Returns: Absolute directory path for saving CLA Network | src/nupic/frameworks/opf/htm_prediction_model.py | def __getNetworkStateDirectory(self, extraDataDir):
"""
extraDataDir:
Model's extra data directory path
Returns: Absolute directory path for saving CLA Network
"""
if self.__restoringFromV1:
if self.getInferenceType() == InferenceType.TemporalNextStep:
leafName =... | def __getNetworkStateDirectory(self, extraDataDir):
"""
extraDataDir:
Model's extra data directory path
Returns: Absolute directory path for saving CLA Network
"""
if self.__restoringFromV1:
if self.getInferenceType() == InferenceType.TemporalNextStep:
leafName =... | [
"extraDataDir",
":",
"Model",
"s",
"extra",
"data",
"directory",
"path",
"Returns",
":",
"Absolute",
"directory",
"path",
"for",
"saving",
"CLA",
"Network"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L1573-L1588 | [
"def",
"__getNetworkStateDirectory",
"(",
"self",
",",
"extraDataDir",
")",
":",
"if",
"self",
".",
"__restoringFromV1",
":",
"if",
"self",
".",
"getInferenceType",
"(",
")",
"==",
"InferenceType",
".",
"TemporalNextStep",
":",
"leafName",
"=",
"'temporal'",
"+"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | HTMPredictionModel.__manglePrivateMemberName | Mangles the given mangled (private) member name; a mangled member name
is one whose name begins with two or more underscores and ends with one
or zero underscores.
privateMemberName:
The private member name (e.g., "__logger")
skipCheck: Pass True to skip test for presence of the d... | src/nupic/frameworks/opf/htm_prediction_model.py | def __manglePrivateMemberName(self, privateMemberName, skipCheck=False):
""" Mangles the given mangled (private) member name; a mangled member name
is one whose name begins with two or more underscores and ends with one
or zero underscores.
privateMemberName:
The private member name (... | def __manglePrivateMemberName(self, privateMemberName, skipCheck=False):
""" Mangles the given mangled (private) member name; a mangled member name
is one whose name begins with two or more underscores and ends with one
or zero underscores.
privateMemberName:
The private member name (... | [
"Mangles",
"the",
"given",
"mangled",
"(",
"private",
")",
"member",
"name",
";",
"a",
"mangled",
"member",
"name",
"is",
"one",
"whose",
"name",
"begins",
"with",
"two",
"or",
"more",
"underscores",
"and",
"ends",
"with",
"one",
"or",
"zero",
"underscores... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L1591-L1618 | [
"def",
"__manglePrivateMemberName",
"(",
"self",
",",
"privateMemberName",
",",
"skipCheck",
"=",
"False",
")",
":",
"assert",
"privateMemberName",
".",
"startswith",
"(",
"\"__\"",
")",
",",
"\"%r doesn't start with __\"",
"%",
"privateMemberName",
"assert",
"not",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | AdaptiveScalarEncoder._setEncoderParams | Set the radius, resolution and range. These values are updated when minval
and/or maxval change. | src/nupic/encoders/adaptive_scalar.py | def _setEncoderParams(self):
"""
Set the radius, resolution and range. These values are updated when minval
and/or maxval change.
"""
self.rangeInternal = float(self.maxval - self.minval)
self.resolution = float(self.rangeInternal) / (self.n - self.w)
self.radius = self.w * self.resolution... | def _setEncoderParams(self):
"""
Set the radius, resolution and range. These values are updated when minval
and/or maxval change.
"""
self.rangeInternal = float(self.maxval - self.minval)
self.resolution = float(self.rangeInternal) / (self.n - self.w)
self.radius = self.w * self.resolution... | [
"Set",
"the",
"radius",
"resolution",
"and",
"range",
".",
"These",
"values",
"are",
"updated",
"when",
"minval",
"and",
"/",
"or",
"maxval",
"change",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/adaptive_scalar.py#L79-L95 | [
"def",
"_setEncoderParams",
"(",
"self",
")",
":",
"self",
".",
"rangeInternal",
"=",
"float",
"(",
"self",
".",
"maxval",
"-",
"self",
".",
"minval",
")",
"self",
".",
"resolution",
"=",
"float",
"(",
"self",
".",
"rangeInternal",
")",
"/",
"(",
"self... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | AdaptiveScalarEncoder.setFieldStats | TODO: document | src/nupic/encoders/adaptive_scalar.py | def setFieldStats(self, fieldName, fieldStats):
"""
TODO: document
"""
#If the stats are not fully formed, ignore.
if fieldStats[fieldName]['min'] == None or \
fieldStats[fieldName]['max'] == None:
return
self.minval = fieldStats[fieldName]['min']
self.maxval = fieldStats[field... | def setFieldStats(self, fieldName, fieldStats):
"""
TODO: document
"""
#If the stats are not fully formed, ignore.
if fieldStats[fieldName]['min'] == None or \
fieldStats[fieldName]['max'] == None:
return
self.minval = fieldStats[fieldName]['min']
self.maxval = fieldStats[field... | [
"TODO",
":",
"document"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/adaptive_scalar.py#L98-L110 | [
"def",
"setFieldStats",
"(",
"self",
",",
"fieldName",
",",
"fieldStats",
")",
":",
"#If the stats are not fully formed, ignore.",
"if",
"fieldStats",
"[",
"fieldName",
"]",
"[",
"'min'",
"]",
"==",
"None",
"or",
"fieldStats",
"[",
"fieldName",
"]",
"[",
"'max'"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | AdaptiveScalarEncoder._setMinAndMax | Potentially change the minval and maxval using input.
**The learn flag is currently not supported by cla regions.** | src/nupic/encoders/adaptive_scalar.py | def _setMinAndMax(self, input, learn):
"""
Potentially change the minval and maxval using input.
**The learn flag is currently not supported by cla regions.**
"""
self.slidingWindow.next(input)
if self.minval is None and self.maxval is None:
self.minval = input
self.maxval = input+... | def _setMinAndMax(self, input, learn):
"""
Potentially change the minval and maxval using input.
**The learn flag is currently not supported by cla regions.**
"""
self.slidingWindow.next(input)
if self.minval is None and self.maxval is None:
self.minval = input
self.maxval = input+... | [
"Potentially",
"change",
"the",
"minval",
"and",
"maxval",
"using",
"input",
".",
"**",
"The",
"learn",
"flag",
"is",
"currently",
"not",
"supported",
"by",
"cla",
"regions",
".",
"**"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/adaptive_scalar.py#L113-L147 | [
"def",
"_setMinAndMax",
"(",
"self",
",",
"input",
",",
"learn",
")",
":",
"self",
".",
"slidingWindow",
".",
"next",
"(",
"input",
")",
"if",
"self",
".",
"minval",
"is",
"None",
"and",
"self",
".",
"maxval",
"is",
"None",
":",
"self",
".",
"minval"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | AdaptiveScalarEncoder.getBucketIndices | [overrides nupic.encoders.scalar.ScalarEncoder.getBucketIndices] | src/nupic/encoders/adaptive_scalar.py | def getBucketIndices(self, input, learn=None):
"""
[overrides nupic.encoders.scalar.ScalarEncoder.getBucketIndices]
"""
self.recordNum +=1
if learn is None:
learn = self._learningEnabled
if type(input) is float and math.isnan(input):
input = SENTINEL_VALUE_FOR_MISSING_DATA
if ... | def getBucketIndices(self, input, learn=None):
"""
[overrides nupic.encoders.scalar.ScalarEncoder.getBucketIndices]
"""
self.recordNum +=1
if learn is None:
learn = self._learningEnabled
if type(input) is float and math.isnan(input):
input = SENTINEL_VALUE_FOR_MISSING_DATA
if ... | [
"[",
"overrides",
"nupic",
".",
"encoders",
".",
"scalar",
".",
"ScalarEncoder",
".",
"getBucketIndices",
"]"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/adaptive_scalar.py#L150-L166 | [
"def",
"getBucketIndices",
"(",
"self",
",",
"input",
",",
"learn",
"=",
"None",
")",
":",
"self",
".",
"recordNum",
"+=",
"1",
"if",
"learn",
"is",
"None",
":",
"learn",
"=",
"self",
".",
"_learningEnabled",
"if",
"type",
"(",
"input",
")",
"is",
"f... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | AdaptiveScalarEncoder.encodeIntoArray | [overrides nupic.encoders.scalar.ScalarEncoder.encodeIntoArray] | src/nupic/encoders/adaptive_scalar.py | def encodeIntoArray(self, input, output,learn=None):
"""
[overrides nupic.encoders.scalar.ScalarEncoder.encodeIntoArray]
"""
self.recordNum +=1
if learn is None:
learn = self._learningEnabled
if input == SENTINEL_VALUE_FOR_MISSING_DATA:
output[0:self.n] = 0
elif not math.isnan... | def encodeIntoArray(self, input, output,learn=None):
"""
[overrides nupic.encoders.scalar.ScalarEncoder.encodeIntoArray]
"""
self.recordNum +=1
if learn is None:
learn = self._learningEnabled
if input == SENTINEL_VALUE_FOR_MISSING_DATA:
output[0:self.n] = 0
elif not math.isnan... | [
"[",
"overrides",
"nupic",
".",
"encoders",
".",
"scalar",
".",
"ScalarEncoder",
".",
"encodeIntoArray",
"]"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/adaptive_scalar.py#L169-L182 | [
"def",
"encodeIntoArray",
"(",
"self",
",",
"input",
",",
"output",
",",
"learn",
"=",
"None",
")",
":",
"self",
".",
"recordNum",
"+=",
"1",
"if",
"learn",
"is",
"None",
":",
"learn",
"=",
"self",
".",
"_learningEnabled",
"if",
"input",
"==",
"SENTINE... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | AdaptiveScalarEncoder.getBucketInfo | [overrides nupic.encoders.scalar.ScalarEncoder.getBucketInfo] | src/nupic/encoders/adaptive_scalar.py | def getBucketInfo(self, buckets):
"""
[overrides nupic.encoders.scalar.ScalarEncoder.getBucketInfo]
"""
if self.minval is None or self.maxval is None:
return [EncoderResult(value=0, scalar=0,
encoding=numpy.zeros(self.n))]
return super(AdaptiveScalarEncoder, self).... | def getBucketInfo(self, buckets):
"""
[overrides nupic.encoders.scalar.ScalarEncoder.getBucketInfo]
"""
if self.minval is None or self.maxval is None:
return [EncoderResult(value=0, scalar=0,
encoding=numpy.zeros(self.n))]
return super(AdaptiveScalarEncoder, self).... | [
"[",
"overrides",
"nupic",
".",
"encoders",
".",
"scalar",
".",
"ScalarEncoder",
".",
"getBucketInfo",
"]"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/adaptive_scalar.py#L184-L193 | [
"def",
"getBucketInfo",
"(",
"self",
",",
"buckets",
")",
":",
"if",
"self",
".",
"minval",
"is",
"None",
"or",
"self",
".",
"maxval",
"is",
"None",
":",
"return",
"[",
"EncoderResult",
"(",
"value",
"=",
"0",
",",
"scalar",
"=",
"0",
",",
"encoding"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | AdaptiveScalarEncoder.topDownCompute | [overrides nupic.encoders.scalar.ScalarEncoder.topDownCompute] | src/nupic/encoders/adaptive_scalar.py | def topDownCompute(self, encoded):
"""
[overrides nupic.encoders.scalar.ScalarEncoder.topDownCompute]
"""
if self.minval is None or self.maxval is None:
return [EncoderResult(value=0, scalar=0,
encoding=numpy.zeros(self.n))]
return super(AdaptiveScalarEncoder, self)... | def topDownCompute(self, encoded):
"""
[overrides nupic.encoders.scalar.ScalarEncoder.topDownCompute]
"""
if self.minval is None or self.maxval is None:
return [EncoderResult(value=0, scalar=0,
encoding=numpy.zeros(self.n))]
return super(AdaptiveScalarEncoder, self)... | [
"[",
"overrides",
"nupic",
".",
"encoders",
".",
"scalar",
".",
"ScalarEncoder",
".",
"topDownCompute",
"]"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/encoders/adaptive_scalar.py#L196-L204 | [
"def",
"topDownCompute",
"(",
"self",
",",
"encoded",
")",
":",
"if",
"self",
".",
"minval",
"is",
"None",
"or",
"self",
".",
"maxval",
"is",
"None",
":",
"return",
"[",
"EncoderResult",
"(",
"value",
"=",
"0",
",",
"scalar",
"=",
"0",
",",
"encoding... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | SwarmTerminator.recordDataPoint | Record the best score for a swarm's generation index (x)
Returns list of swarmIds to terminate. | src/nupic/swarming/hypersearch/swarm_terminator.py | def recordDataPoint(self, swarmId, generation, errScore):
"""Record the best score for a swarm's generation index (x)
Returns list of swarmIds to terminate.
"""
terminatedSwarms = []
# Append score to existing swarm.
if swarmId in self.swarmScores:
entry = self.swarmScores[swarmId]
... | def recordDataPoint(self, swarmId, generation, errScore):
"""Record the best score for a swarm's generation index (x)
Returns list of swarmIds to terminate.
"""
terminatedSwarms = []
# Append score to existing swarm.
if swarmId in self.swarmScores:
entry = self.swarmScores[swarmId]
... | [
"Record",
"the",
"best",
"score",
"for",
"a",
"swarm",
"s",
"generation",
"index",
"(",
"x",
")",
"Returns",
"list",
"of",
"swarmIds",
"to",
"terminate",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/swarm_terminator.py#L68-L118 | [
"def",
"recordDataPoint",
"(",
"self",
",",
"swarmId",
",",
"generation",
",",
"errScore",
")",
":",
"terminatedSwarms",
"=",
"[",
"]",
"# Append score to existing swarm.",
"if",
"swarmId",
"in",
"self",
".",
"swarmScores",
":",
"entry",
"=",
"self",
".",
"swa... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PermuteFloat.getState | See comments in base class. | src/nupic/swarming/hypersearch/permutation_helpers.py | def getState(self):
"""See comments in base class."""
return dict(_position = self._position,
position = self.getPosition(),
velocity = self._velocity,
bestPosition = self._bestPosition,
bestResult = self._bestResult) | def getState(self):
"""See comments in base class."""
return dict(_position = self._position,
position = self.getPosition(),
velocity = self._velocity,
bestPosition = self._bestPosition,
bestResult = self._bestResult) | [
"See",
"comments",
"in",
"base",
"class",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/permutation_helpers.py#L164-L170 | [
"def",
"getState",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"_position",
"=",
"self",
".",
"_position",
",",
"position",
"=",
"self",
".",
"getPosition",
"(",
")",
",",
"velocity",
"=",
"self",
".",
"_velocity",
",",
"bestPosition",
"=",
"self",
"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PermuteFloat.setState | See comments in base class. | src/nupic/swarming/hypersearch/permutation_helpers.py | def setState(self, state):
"""See comments in base class."""
self._position = state['_position']
self._velocity = state['velocity']
self._bestPosition = state['bestPosition']
self._bestResult = state['bestResult'] | def setState(self, state):
"""See comments in base class."""
self._position = state['_position']
self._velocity = state['velocity']
self._bestPosition = state['bestPosition']
self._bestResult = state['bestResult'] | [
"See",
"comments",
"in",
"base",
"class",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/permutation_helpers.py#L172-L177 | [
"def",
"setState",
"(",
"self",
",",
"state",
")",
":",
"self",
".",
"_position",
"=",
"state",
"[",
"'_position'",
"]",
"self",
".",
"_velocity",
"=",
"state",
"[",
"'velocity'",
"]",
"self",
".",
"_bestPosition",
"=",
"state",
"[",
"'bestPosition'",
"]... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PermuteFloat.getPosition | See comments in base class. | src/nupic/swarming/hypersearch/permutation_helpers.py | def getPosition(self):
"""See comments in base class."""
if self.stepSize is None:
return self._position
# Find nearest step
numSteps = (self._position - self.min) / self.stepSize
numSteps = int(round(numSteps))
position = self.min + (numSteps * self.stepSize)
position = max(self.min... | def getPosition(self):
"""See comments in base class."""
if self.stepSize is None:
return self._position
# Find nearest step
numSteps = (self._position - self.min) / self.stepSize
numSteps = int(round(numSteps))
position = self.min + (numSteps * self.stepSize)
position = max(self.min... | [
"See",
"comments",
"in",
"base",
"class",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/permutation_helpers.py#L179-L190 | [
"def",
"getPosition",
"(",
"self",
")",
":",
"if",
"self",
".",
"stepSize",
"is",
"None",
":",
"return",
"self",
".",
"_position",
"# Find nearest step",
"numSteps",
"=",
"(",
"self",
".",
"_position",
"-",
"self",
".",
"min",
")",
"/",
"self",
".",
"s... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PermuteFloat.agitate | See comments in base class. | src/nupic/swarming/hypersearch/permutation_helpers.py | def agitate(self):
"""See comments in base class."""
# Increase velocity enough that it will be higher the next time
# newPosition() is called. We know that newPosition multiplies by inertia,
# so take that into account.
self._velocity *= 1.5 / self._inertia
# Clip velocity
maxV = (self.max... | def agitate(self):
"""See comments in base class."""
# Increase velocity enough that it will be higher the next time
# newPosition() is called. We know that newPosition multiplies by inertia,
# so take that into account.
self._velocity *= 1.5 / self._inertia
# Clip velocity
maxV = (self.max... | [
"See",
"comments",
"in",
"base",
"class",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/permutation_helpers.py#L192-L210 | [
"def",
"agitate",
"(",
"self",
")",
":",
"# Increase velocity enough that it will be higher the next time",
"# newPosition() is called. We know that newPosition multiplies by inertia,",
"# so take that into account.",
"self",
".",
"_velocity",
"*=",
"1.5",
"/",
"self",
".",
"_inert... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PermuteFloat.newPosition | See comments in base class. | src/nupic/swarming/hypersearch/permutation_helpers.py | def newPosition(self, globalBestPosition, rng):
"""See comments in base class."""
# First, update the velocity. The new velocity is given as:
# v = (inertia * v) + (cogRate * r1 * (localBest-pos))
# + (socRate * r2 * (globalBest-pos))
#
# where r1 and r2 are random numbers be... | def newPosition(self, globalBestPosition, rng):
"""See comments in base class."""
# First, update the velocity. The new velocity is given as:
# v = (inertia * v) + (cogRate * r1 * (localBest-pos))
# + (socRate * r2 * (globalBest-pos))
#
# where r1 and r2 are random numbers be... | [
"See",
"comments",
"in",
"base",
"class",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/permutation_helpers.py#L212-L236 | [
"def",
"newPosition",
"(",
"self",
",",
"globalBestPosition",
",",
"rng",
")",
":",
"# First, update the velocity. The new velocity is given as:",
"# v = (inertia * v) + (cogRate * r1 * (localBest-pos))",
"# + (socRate * r2 * (globalBest-pos))",
"#",
"# where r1 and r... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PermuteFloat.pushAwayFrom | See comments in base class. | src/nupic/swarming/hypersearch/permutation_helpers.py | def pushAwayFrom(self, otherPositions, rng):
"""See comments in base class."""
# If min and max are the same, nothing to do
if self.max == self.min:
return
# How many potential other positions to evaluate?
numPositions = len(otherPositions) * 4
if numPositions == 0:
return
# As... | def pushAwayFrom(self, otherPositions, rng):
"""See comments in base class."""
# If min and max are the same, nothing to do
if self.max == self.min:
return
# How many potential other positions to evaluate?
numPositions = len(otherPositions) * 4
if numPositions == 0:
return
# As... | [
"See",
"comments",
"in",
"base",
"class",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/permutation_helpers.py#L238-L277 | [
"def",
"pushAwayFrom",
"(",
"self",
",",
"otherPositions",
",",
"rng",
")",
":",
"# If min and max are the same, nothing to do",
"if",
"self",
".",
"max",
"==",
"self",
".",
"min",
":",
"return",
"# How many potential other positions to evaluate?",
"numPositions",
"=",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PermuteFloat.resetVelocity | See comments in base class. | src/nupic/swarming/hypersearch/permutation_helpers.py | def resetVelocity(self, rng):
"""See comments in base class."""
maxVelocity = (self.max - self.min) / 5.0
self._velocity = maxVelocity #min(abs(self._velocity), maxVelocity)
self._velocity *= rng.choice([1, -1]) | def resetVelocity(self, rng):
"""See comments in base class."""
maxVelocity = (self.max - self.min) / 5.0
self._velocity = maxVelocity #min(abs(self._velocity), maxVelocity)
self._velocity *= rng.choice([1, -1]) | [
"See",
"comments",
"in",
"base",
"class",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/permutation_helpers.py#L279-L283 | [
"def",
"resetVelocity",
"(",
"self",
",",
"rng",
")",
":",
"maxVelocity",
"=",
"(",
"self",
".",
"max",
"-",
"self",
".",
"min",
")",
"/",
"5.0",
"self",
".",
"_velocity",
"=",
"maxVelocity",
"#min(abs(self._velocity), maxVelocity)",
"self",
".",
"_velocity"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PermuteInt.getPosition | See comments in base class. | src/nupic/swarming/hypersearch/permutation_helpers.py | def getPosition(self):
"""See comments in base class."""
position = super(PermuteInt, self).getPosition()
position = int(round(position))
return position | def getPosition(self):
"""See comments in base class."""
position = super(PermuteInt, self).getPosition()
position = int(round(position))
return position | [
"See",
"comments",
"in",
"base",
"class",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/permutation_helpers.py#L302-L306 | [
"def",
"getPosition",
"(",
"self",
")",
":",
"position",
"=",
"super",
"(",
"PermuteInt",
",",
"self",
")",
".",
"getPosition",
"(",
")",
"position",
"=",
"int",
"(",
"round",
"(",
"position",
")",
")",
"return",
"position"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PermuteChoices.getState | See comments in base class. | src/nupic/swarming/hypersearch/permutation_helpers.py | def getState(self):
"""See comments in base class."""
return dict(_position = self.getPosition(),
position = self.getPosition(),
velocity = None,
bestPosition = self.choices[self._bestPositionIdx],
bestResult = self._bestResult) | def getState(self):
"""See comments in base class."""
return dict(_position = self.getPosition(),
position = self.getPosition(),
velocity = None,
bestPosition = self.choices[self._bestPositionIdx],
bestResult = self._bestResult) | [
"See",
"comments",
"in",
"base",
"class",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/permutation_helpers.py#L338-L344 | [
"def",
"getState",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"_position",
"=",
"self",
".",
"getPosition",
"(",
")",
",",
"position",
"=",
"self",
".",
"getPosition",
"(",
")",
",",
"velocity",
"=",
"None",
",",
"bestPosition",
"=",
"self",
".",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PermuteChoices.setState | See comments in base class. | src/nupic/swarming/hypersearch/permutation_helpers.py | def setState(self, state):
"""See comments in base class."""
self._positionIdx = self.choices.index(state['_position'])
self._bestPositionIdx = self.choices.index(state['bestPosition'])
self._bestResult = state['bestResult'] | def setState(self, state):
"""See comments in base class."""
self._positionIdx = self.choices.index(state['_position'])
self._bestPositionIdx = self.choices.index(state['bestPosition'])
self._bestResult = state['bestResult'] | [
"See",
"comments",
"in",
"base",
"class",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/permutation_helpers.py#L346-L350 | [
"def",
"setState",
"(",
"self",
",",
"state",
")",
":",
"self",
".",
"_positionIdx",
"=",
"self",
".",
"choices",
".",
"index",
"(",
"state",
"[",
"'_position'",
"]",
")",
"self",
".",
"_bestPositionIdx",
"=",
"self",
".",
"choices",
".",
"index",
"(",... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PermuteChoices.setResultsPerChoice | Setup our resultsPerChoice history based on the passed in
resultsPerChoice.
For example, if this variable has the following choices:
['a', 'b', 'c']
resultsPerChoice will have up to 3 elements, each element is a tuple
containing (choiceValue, errors) where errors is the list of errors
receiv... | src/nupic/swarming/hypersearch/permutation_helpers.py | def setResultsPerChoice(self, resultsPerChoice):
"""Setup our resultsPerChoice history based on the passed in
resultsPerChoice.
For example, if this variable has the following choices:
['a', 'b', 'c']
resultsPerChoice will have up to 3 elements, each element is a tuple
containing (choiceValu... | def setResultsPerChoice(self, resultsPerChoice):
"""Setup our resultsPerChoice history based on the passed in
resultsPerChoice.
For example, if this variable has the following choices:
['a', 'b', 'c']
resultsPerChoice will have up to 3 elements, each element is a tuple
containing (choiceValu... | [
"Setup",
"our",
"resultsPerChoice",
"history",
"based",
"on",
"the",
"passed",
"in",
"resultsPerChoice",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/permutation_helpers.py#L352-L369 | [
"def",
"setResultsPerChoice",
"(",
"self",
",",
"resultsPerChoice",
")",
":",
"# Keep track of the results obtained for each choice.",
"self",
".",
"_resultsPerChoice",
"=",
"[",
"[",
"]",
"]",
"*",
"len",
"(",
"self",
".",
"choices",
")",
"for",
"(",
"choiceValue... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PermuteChoices.newPosition | See comments in base class. | src/nupic/swarming/hypersearch/permutation_helpers.py | def newPosition(self, globalBestPosition, rng):
"""See comments in base class."""
# Compute the mean score per choice.
numChoices = len(self.choices)
meanScorePerChoice = []
overallSum = 0
numResults = 0
for i in range(numChoices):
if len(self._resultsPerChoice[i]) > 0:
data =... | def newPosition(self, globalBestPosition, rng):
"""See comments in base class."""
# Compute the mean score per choice.
numChoices = len(self.choices)
meanScorePerChoice = []
overallSum = 0
numResults = 0
for i in range(numChoices):
if len(self._resultsPerChoice[i]) > 0:
data =... | [
"See",
"comments",
"in",
"base",
"class",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/permutation_helpers.py#L381-L434 | [
"def",
"newPosition",
"(",
"self",
",",
"globalBestPosition",
",",
"rng",
")",
":",
"# Compute the mean score per choice.",
"numChoices",
"=",
"len",
"(",
"self",
".",
"choices",
")",
"meanScorePerChoice",
"=",
"[",
"]",
"overallSum",
"=",
"0",
"numResults",
"="... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PermuteChoices.pushAwayFrom | See comments in base class. | src/nupic/swarming/hypersearch/permutation_helpers.py | def pushAwayFrom(self, otherPositions, rng):
"""See comments in base class."""
# Get the count of how many in each position
positions = [self.choices.index(x) for x in otherPositions]
positionCounts = [0] * len(self.choices)
for pos in positions:
positionCounts[pos] += 1
self._positionId... | def pushAwayFrom(self, otherPositions, rng):
"""See comments in base class."""
# Get the count of how many in each position
positions = [self.choices.index(x) for x in otherPositions]
positionCounts = [0] * len(self.choices)
for pos in positions:
positionCounts[pos] += 1
self._positionId... | [
"See",
"comments",
"in",
"base",
"class",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/permutation_helpers.py#L436-L446 | [
"def",
"pushAwayFrom",
"(",
"self",
",",
"otherPositions",
",",
"rng",
")",
":",
"# Get the count of how many in each position",
"positions",
"=",
"[",
"self",
".",
"choices",
".",
"index",
"(",
"x",
")",
"for",
"x",
"in",
"otherPositions",
"]",
"positionCounts"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | PermuteEncoder.getDict | Return a dict that can be used to construct this encoder. This dict
can be passed directly to the addMultipleEncoders() method of the
multi encoder.
Parameters:
----------------------------------------------------------------------
encoderName: name of the encoder
flattenedChosenValu... | src/nupic/swarming/hypersearch/permutation_helpers.py | def getDict(self, encoderName, flattenedChosenValues):
""" Return a dict that can be used to construct this encoder. This dict
can be passed directly to the addMultipleEncoders() method of the
multi encoder.
Parameters:
----------------------------------------------------------------------
enco... | def getDict(self, encoderName, flattenedChosenValues):
""" Return a dict that can be used to construct this encoder. This dict
can be passed directly to the addMultipleEncoders() method of the
multi encoder.
Parameters:
----------------------------------------------------------------------
enco... | [
"Return",
"a",
"dict",
"that",
"can",
"be",
"used",
"to",
"construct",
"this",
"encoder",
".",
"This",
"dict",
"can",
"be",
"passed",
"directly",
"to",
"the",
"addMultipleEncoders",
"()",
"method",
"of",
"the",
"multi",
"encoder",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/permutation_helpers.py#L478-L518 | [
"def",
"getDict",
"(",
"self",
",",
"encoderName",
",",
"flattenedChosenValues",
")",
":",
"encoder",
"=",
"dict",
"(",
"fieldname",
"=",
"self",
".",
"fieldName",
",",
"name",
"=",
"self",
".",
"name",
")",
"# Get the position of each encoder argument",
"for",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | BasicPredictionMetricsLogger._translateMetricsToJSON | Translates the given metrics value to JSON string
metrics: A list of dictionaries per OPFTaskDriver.getMetrics():
Returns: JSON string representing the given metrics object. | src/nupic/frameworks/opf/opf_basic_environment.py | def _translateMetricsToJSON(self, metrics, label):
""" Translates the given metrics value to JSON string
metrics: A list of dictionaries per OPFTaskDriver.getMetrics():
Returns: JSON string representing the given metrics object.
"""
# Transcode the MetricValueElement values into JSO... | def _translateMetricsToJSON(self, metrics, label):
""" Translates the given metrics value to JSON string
metrics: A list of dictionaries per OPFTaskDriver.getMetrics():
Returns: JSON string representing the given metrics object.
"""
# Transcode the MetricValueElement values into JSO... | [
"Translates",
"the",
"given",
"metrics",
"value",
"to",
"JSON",
"string"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/opf_basic_environment.py#L204-L237 | [
"def",
"_translateMetricsToJSON",
"(",
"self",
",",
"metrics",
",",
"label",
")",
":",
"# Transcode the MetricValueElement values into JSON-compatible",
"# structure",
"metricsDict",
"=",
"metrics",
"# Convert the structure to a display-friendly JSON string",
"def",
"_mapNumpyValue... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _BasicPredictionWriter.__openDatafile | Open the data file and write the header row | src/nupic/frameworks/opf/opf_basic_environment.py | def __openDatafile(self, modelResult):
"""Open the data file and write the header row"""
# Write reset bit
resetFieldMeta = FieldMetaInfo(
name="reset",
type=FieldMetaType.integer,
special = FieldMetaSpecial.reset)
self.__outputFieldsMeta.append(resetFieldMeta)
# --------------... | def __openDatafile(self, modelResult):
"""Open the data file and write the header row"""
# Write reset bit
resetFieldMeta = FieldMetaInfo(
name="reset",
type=FieldMetaType.integer,
special = FieldMetaSpecial.reset)
self.__outputFieldsMeta.append(resetFieldMeta)
# --------------... | [
"Open",
"the",
"data",
"file",
"and",
"write",
"the",
"header",
"row"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/opf_basic_environment.py#L346-L457 | [
"def",
"__openDatafile",
"(",
"self",
",",
"modelResult",
")",
":",
"# Write reset bit",
"resetFieldMeta",
"=",
"FieldMetaInfo",
"(",
"name",
"=",
"\"reset\"",
",",
"type",
"=",
"FieldMetaType",
".",
"integer",
",",
"special",
"=",
"FieldMetaSpecial",
".",
"rese... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _BasicPredictionWriter.setLoggedMetrics | Tell the writer which metrics should be written
Parameters:
-----------------------------------------------------------------------
metricsNames: A list of metric lables to be written | src/nupic/frameworks/opf/opf_basic_environment.py | def setLoggedMetrics(self, metricNames):
""" Tell the writer which metrics should be written
Parameters:
-----------------------------------------------------------------------
metricsNames: A list of metric lables to be written
"""
if metricNames is None:
self.__metricNames = set([])
... | def setLoggedMetrics(self, metricNames):
""" Tell the writer which metrics should be written
Parameters:
-----------------------------------------------------------------------
metricsNames: A list of metric lables to be written
"""
if metricNames is None:
self.__metricNames = set([])
... | [
"Tell",
"the",
"writer",
"which",
"metrics",
"should",
"be",
"written"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/opf_basic_environment.py#L460-L470 | [
"def",
"setLoggedMetrics",
"(",
"self",
",",
"metricNames",
")",
":",
"if",
"metricNames",
"is",
"None",
":",
"self",
".",
"__metricNames",
"=",
"set",
"(",
"[",
"]",
")",
"else",
":",
"self",
".",
"__metricNames",
"=",
"set",
"(",
"metricNames",
")"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _BasicPredictionWriter.__getListMetaInfo | Get field metadata information for inferences that are of list type
TODO: Right now we assume list inferences are associated with the input field
metadata | src/nupic/frameworks/opf/opf_basic_environment.py | def __getListMetaInfo(self, inferenceElement):
""" Get field metadata information for inferences that are of list type
TODO: Right now we assume list inferences are associated with the input field
metadata
"""
fieldMetaInfo = []
inferenceLabel = InferenceElement.getLabel(inferenceElement)
f... | def __getListMetaInfo(self, inferenceElement):
""" Get field metadata information for inferences that are of list type
TODO: Right now we assume list inferences are associated with the input field
metadata
"""
fieldMetaInfo = []
inferenceLabel = InferenceElement.getLabel(inferenceElement)
f... | [
"Get",
"field",
"metadata",
"information",
"for",
"inferences",
"that",
"are",
"of",
"list",
"type",
"TODO",
":",
"Right",
"now",
"we",
"assume",
"list",
"inferences",
"are",
"associated",
"with",
"the",
"input",
"field",
"metadata"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/opf_basic_environment.py#L485-L510 | [
"def",
"__getListMetaInfo",
"(",
"self",
",",
"inferenceElement",
")",
":",
"fieldMetaInfo",
"=",
"[",
"]",
"inferenceLabel",
"=",
"InferenceElement",
".",
"getLabel",
"(",
"inferenceElement",
")",
"for",
"inputFieldMeta",
"in",
"self",
".",
"__inputFieldsMeta",
"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _BasicPredictionWriter.__getDictMetaInfo | Get field metadate information for inferences that are of dict type | src/nupic/frameworks/opf/opf_basic_environment.py | def __getDictMetaInfo(self, inferenceElement, inferenceDict):
"""Get field metadate information for inferences that are of dict type"""
fieldMetaInfo = []
inferenceLabel = InferenceElement.getLabel(inferenceElement)
if InferenceElement.getInputElement(inferenceElement):
fieldMetaInfo.append(Field... | def __getDictMetaInfo(self, inferenceElement, inferenceDict):
"""Get field metadate information for inferences that are of dict type"""
fieldMetaInfo = []
inferenceLabel = InferenceElement.getLabel(inferenceElement)
if InferenceElement.getInputElement(inferenceElement):
fieldMetaInfo.append(Field... | [
"Get",
"field",
"metadate",
"information",
"for",
"inferences",
"that",
"are",
"of",
"dict",
"type"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/opf_basic_environment.py#L513-L530 | [
"def",
"__getDictMetaInfo",
"(",
"self",
",",
"inferenceElement",
",",
"inferenceDict",
")",
":",
"fieldMetaInfo",
"=",
"[",
"]",
"inferenceLabel",
"=",
"InferenceElement",
".",
"getLabel",
"(",
"inferenceElement",
")",
"if",
"InferenceElement",
".",
"getInputElemen... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _BasicPredictionWriter.append | [virtual method override] Emits a single prediction as input versus
predicted.
modelResult: An opf_utils.ModelResult object that contains the model input
and output for the current timestep. | src/nupic/frameworks/opf/opf_basic_environment.py | def append(self, modelResult):
""" [virtual method override] Emits a single prediction as input versus
predicted.
modelResult: An opf_utils.ModelResult object that contains the model input
and output for the current timestep.
"""
#print "DEBUG: _BasicPredictionWriter: writin... | def append(self, modelResult):
""" [virtual method override] Emits a single prediction as input versus
predicted.
modelResult: An opf_utils.ModelResult object that contains the model input
and output for the current timestep.
"""
#print "DEBUG: _BasicPredictionWriter: writin... | [
"[",
"virtual",
"method",
"override",
"]",
"Emits",
"a",
"single",
"prediction",
"as",
"input",
"versus",
"predicted",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/opf_basic_environment.py#L533-L610 | [
"def",
"append",
"(",
"self",
",",
"modelResult",
")",
":",
"#print \"DEBUG: _BasicPredictionWriter: writing modelResult: %r\" % (modelResult,)",
"# If there are no inferences, don't write anything",
"inferences",
"=",
"modelResult",
".",
"inferences",
"hasInferences",
"=",
"False"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _BasicPredictionWriter.checkpoint | [virtual method override] Save a checkpoint of the prediction output
stream. The checkpoint comprises up to maxRows of the most recent inference
records.
Parameters:
----------------------------------------------------------------------
checkpointSink: A File-like object where predictions check... | src/nupic/frameworks/opf/opf_basic_environment.py | def checkpoint(self, checkpointSink, maxRows):
""" [virtual method override] Save a checkpoint of the prediction output
stream. The checkpoint comprises up to maxRows of the most recent inference
records.
Parameters:
----------------------------------------------------------------------
checkpo... | def checkpoint(self, checkpointSink, maxRows):
""" [virtual method override] Save a checkpoint of the prediction output
stream. The checkpoint comprises up to maxRows of the most recent inference
records.
Parameters:
----------------------------------------------------------------------
checkpo... | [
"[",
"virtual",
"method",
"override",
"]",
"Save",
"a",
"checkpoint",
"of",
"the",
"prediction",
"output",
"stream",
".",
"The",
"checkpoint",
"comprises",
"up",
"to",
"maxRows",
"of",
"the",
"most",
"recent",
"inference",
"records",
"."
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/opf_basic_environment.py#L612-L682 | [
"def",
"checkpoint",
"(",
"self",
",",
"checkpointSink",
",",
"maxRows",
")",
":",
"checkpointSink",
".",
"truncate",
"(",
")",
"if",
"self",
".",
"__dataset",
"is",
"None",
":",
"if",
"self",
".",
"__checkpointCache",
"is",
"not",
"None",
":",
"self",
"... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | TemporalPredictionLogAdapter.update | Queue up the T(i+1) prediction value and emit a T(i)
input/prediction pair, if possible. E.g., if the previous T(i-1)
iteration was learn-only, then we would not have a T(i) prediction in our
FIFO and would not be able to emit a meaningful input/prediction
pair.
modelResult: An opf_utils.ModelR... | src/nupic/frameworks/opf/opf_basic_environment.py | def update(self, modelResult):
""" Queue up the T(i+1) prediction value and emit a T(i)
input/prediction pair, if possible. E.g., if the previous T(i-1)
iteration was learn-only, then we would not have a T(i) prediction in our
FIFO and would not be able to emit a meaningful input/prediction
pair.
... | def update(self, modelResult):
""" Queue up the T(i+1) prediction value and emit a T(i)
input/prediction pair, if possible. E.g., if the previous T(i-1)
iteration was learn-only, then we would not have a T(i) prediction in our
FIFO and would not be able to emit a meaningful input/prediction
pair.
... | [
"Queue",
"up",
"the",
"T",
"(",
"i",
"+",
"1",
")",
"prediction",
"value",
"and",
"emit",
"a",
"T",
"(",
"i",
")",
"input",
"/",
"prediction",
"pair",
"if",
"possible",
".",
"E",
".",
"g",
".",
"if",
"the",
"previous",
"T",
"(",
"i",
"-",
"1",
... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/opf_basic_environment.py#L748-L758 | [
"def",
"update",
"(",
"self",
",",
"modelResult",
")",
":",
"self",
".",
"__writer",
".",
"append",
"(",
"self",
".",
"__inferenceShifter",
".",
"shift",
"(",
"modelResult",
")",
")"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _FileUtils.createExperimentInferenceDir | Creates the inference output directory for the given experiment
experimentDir: experiment directory path that contains description.py
Returns: path of the inference output directory | src/nupic/frameworks/opf/opf_basic_environment.py | def createExperimentInferenceDir(cls, experimentDir):
""" Creates the inference output directory for the given experiment
experimentDir: experiment directory path that contains description.py
Returns: path of the inference output directory
"""
path = cls.getExperimentInferenceDirPath(experimentD... | def createExperimentInferenceDir(cls, experimentDir):
""" Creates the inference output directory for the given experiment
experimentDir: experiment directory path that contains description.py
Returns: path of the inference output directory
"""
path = cls.getExperimentInferenceDirPath(experimentD... | [
"Creates",
"the",
"inference",
"output",
"directory",
"for",
"the",
"given",
"experiment"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/opf_basic_environment.py#L898-L909 | [
"def",
"createExperimentInferenceDir",
"(",
"cls",
",",
"experimentDir",
")",
":",
"path",
"=",
"cls",
".",
"getExperimentInferenceDirPath",
"(",
"experimentDir",
")",
"cls",
".",
"makeDirectory",
"(",
"path",
")",
"return",
"path"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _generateModel0 | Generate the initial, first order, and second order transition
probabilities for 'model0'. For this model, we generate the following
set of sequences:
1-2-3 (4X)
1-2-4 (1X)
5-2-3 (1X)
5-2-4 (4X)
Parameters:
----------------------------------------------------------------------
numCate... | src/nupic/datafiles/extra/secondOrder/makeDataset.py | def _generateModel0(numCategories):
""" Generate the initial, first order, and second order transition
probabilities for 'model0'. For this model, we generate the following
set of sequences:
1-2-3 (4X)
1-2-4 (1X)
5-2-3 (1X)
5-2-4 (4X)
Parameters:
--------------------------------------... | def _generateModel0(numCategories):
""" Generate the initial, first order, and second order transition
probabilities for 'model0'. For this model, we generate the following
set of sequences:
1-2-3 (4X)
1-2-4 (1X)
5-2-3 (1X)
5-2-4 (4X)
Parameters:
--------------------------------------... | [
"Generate",
"the",
"initial",
"first",
"order",
"and",
"second",
"order",
"transition",
"probabilities",
"for",
"model0",
".",
"For",
"this",
"model",
"we",
"generate",
"the",
"following",
"set",
"of",
"sequences",
":",
"1",
"-",
"2",
"-",
"3",
"(",
"4X",
... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/datafiles/extra/secondOrder/makeDataset.py#L34-L129 | [
"def",
"_generateModel0",
"(",
"numCategories",
")",
":",
"# ===============================================================",
"# Let's model the following:",
"# a-b-c (4X)",
"# a-b-d (1X)",
"# e-b-c (1X)",
"# e-b-d (4X)",
"# --------------------------------------------------------------... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _generateModel1 | Generate the initial, first order, and second order transition
probabilities for 'model1'. For this model, we generate the following
set of sequences:
0-10-15 (1X)
0-11-16 (1X)
0-12-17 (1X)
0-13-18 (1X)
0-14-19 (1X)
1-10-20 (1X)
1-11-21 (1X)
1-12-22 (1X)
1-13-23 (1X)
1-14-24 (1X)
Par... | src/nupic/datafiles/extra/secondOrder/makeDataset.py | def _generateModel1(numCategories):
""" Generate the initial, first order, and second order transition
probabilities for 'model1'. For this model, we generate the following
set of sequences:
0-10-15 (1X)
0-11-16 (1X)
0-12-17 (1X)
0-13-18 (1X)
0-14-19 (1X)
1-10-20 (1X)
1-11-21 (1X)
1-12-22 (1X)... | def _generateModel1(numCategories):
""" Generate the initial, first order, and second order transition
probabilities for 'model1'. For this model, we generate the following
set of sequences:
0-10-15 (1X)
0-11-16 (1X)
0-12-17 (1X)
0-13-18 (1X)
0-14-19 (1X)
1-10-20 (1X)
1-11-21 (1X)
1-12-22 (1X)... | [
"Generate",
"the",
"initial",
"first",
"order",
"and",
"second",
"order",
"transition",
"probabilities",
"for",
"model1",
".",
"For",
"this",
"model",
"we",
"generate",
"the",
"following",
"set",
"of",
"sequences",
":",
"0",
"-",
"10",
"-",
"15",
"(",
"1X"... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/datafiles/extra/secondOrder/makeDataset.py#L133-L257 | [
"def",
"_generateModel1",
"(",
"numCategories",
")",
":",
"# --------------------------------------------------------------------",
"# Initial probabilities, 0 and 1 equally likely",
"initProb",
"=",
"numpy",
".",
"zeros",
"(",
"numCategories",
")",
"initProb",
"[",
"0",
"]",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _generateModel2 | Generate the initial, first order, and second order transition
probabilities for 'model2'. For this model, we generate peaked random
transitions using dirichlet distributions.
Parameters:
----------------------------------------------------------------------
numCategories: Number of categories
alp... | src/nupic/datafiles/extra/secondOrder/makeDataset.py | def _generateModel2(numCategories, alpha=0.25):
""" Generate the initial, first order, and second order transition
probabilities for 'model2'. For this model, we generate peaked random
transitions using dirichlet distributions.
Parameters:
-----------------------------------------------------------------... | def _generateModel2(numCategories, alpha=0.25):
""" Generate the initial, first order, and second order transition
probabilities for 'model2'. For this model, we generate peaked random
transitions using dirichlet distributions.
Parameters:
-----------------------------------------------------------------... | [
"Generate",
"the",
"initial",
"first",
"order",
"and",
"second",
"order",
"transition",
"probabilities",
"for",
"model2",
".",
"For",
"this",
"model",
"we",
"generate",
"peaked",
"random",
"transitions",
"using",
"dirichlet",
"distributions",
".",
"Parameters",
":... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/datafiles/extra/secondOrder/makeDataset.py#L261-L335 | [
"def",
"_generateModel2",
"(",
"numCategories",
",",
"alpha",
"=",
"0.25",
")",
":",
"# --------------------------------------------------------------------",
"# All initial probabilities, are equally likely",
"initProb",
"=",
"numpy",
".",
"ones",
"(",
"numCategories",
")",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _generateFile | Generate a set of records reflecting a set of probabilities.
Parameters:
----------------------------------------------------------------
filename: name of .csv file to generate
numRecords: number of records to generate
categoryList: list of category names
initProb: Initial prob... | src/nupic/datafiles/extra/secondOrder/makeDataset.py | def _generateFile(filename, numRecords, categoryList, initProb,
firstOrderProb, secondOrderProb, seqLen, numNoise=0, resetsEvery=None):
""" Generate a set of records reflecting a set of probabilities.
Parameters:
----------------------------------------------------------------
filename: name o... | def _generateFile(filename, numRecords, categoryList, initProb,
firstOrderProb, secondOrderProb, seqLen, numNoise=0, resetsEvery=None):
""" Generate a set of records reflecting a set of probabilities.
Parameters:
----------------------------------------------------------------
filename: name o... | [
"Generate",
"a",
"set",
"of",
"records",
"reflecting",
"a",
"set",
"of",
"probabilities",
".",
"Parameters",
":",
"----------------------------------------------------------------",
"filename",
":",
"name",
"of",
".",
"csv",
"file",
"to",
"generate",
"numRecords",
":"... | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/datafiles/extra/secondOrder/makeDataset.py#L339-L454 | [
"def",
"_generateFile",
"(",
"filename",
",",
"numRecords",
",",
"categoryList",
",",
"initProb",
",",
"firstOrderProb",
",",
"secondOrderProb",
",",
"seqLen",
",",
"numNoise",
"=",
"0",
",",
"resetsEvery",
"=",
"None",
")",
":",
"# Create the file",
"print",
... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _allow_new_attributes | A decorator that maintains the attribute lock state of an object
It coperates with the LockAttributesMetaclass (see bellow) that replaces
the __setattr__ method with a custom one that checks the _canAddAttributes
counter and allows setting new attributes only if _canAddAttributes > 0.
New attributes can be se... | src/nupic/support/lock_attributes.py | def _allow_new_attributes(f):
"""A decorator that maintains the attribute lock state of an object
It coperates with the LockAttributesMetaclass (see bellow) that replaces
the __setattr__ method with a custom one that checks the _canAddAttributes
counter and allows setting new attributes only if _canAddAttribut... | def _allow_new_attributes(f):
"""A decorator that maintains the attribute lock state of an object
It coperates with the LockAttributesMetaclass (see bellow) that replaces
the __setattr__ method with a custom one that checks the _canAddAttributes
counter and allows setting new attributes only if _canAddAttribut... | [
"A",
"decorator",
"that",
"maintains",
"the",
"attribute",
"lock",
"state",
"of",
"an",
"object"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/support/lock_attributes.py#L37-L79 | [
"def",
"_allow_new_attributes",
"(",
"f",
")",
":",
"def",
"decorated",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"\"\"\"The decorated function that replaces __init__() or __setstate__()\n\n \"\"\"",
"# Run the original function",
"if",
"not",
"ha... | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
valid | _simple_init | trivial init method that just calls base class's __init__()
This method is attached to classes that don't define __init__(). It is needed
because LockAttributesMetaclass must decorate the __init__() method of
its target class. | src/nupic/support/lock_attributes.py | def _simple_init(self, *args, **kw):
"""trivial init method that just calls base class's __init__()
This method is attached to classes that don't define __init__(). It is needed
because LockAttributesMetaclass must decorate the __init__() method of
its target class.
"""
type(self).__base__.__init__(self, *... | def _simple_init(self, *args, **kw):
"""trivial init method that just calls base class's __init__()
This method is attached to classes that don't define __init__(). It is needed
because LockAttributesMetaclass must decorate the __init__() method of
its target class.
"""
type(self).__base__.__init__(self, *... | [
"trivial",
"init",
"method",
"that",
"just",
"calls",
"base",
"class",
"s",
"__init__",
"()"
] | numenta/nupic | python | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/support/lock_attributes.py#L81-L88 | [
"def",
"_simple_init",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"type",
"(",
"self",
")",
".",
"__base__",
".",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")"
] | 5922fafffdccc8812e72b3324965ad2f7d4bbdad |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.