Skip to content

Commit

Permalink
Merge pull request #3665 from scottpurdy/master
Browse files Browse the repository at this point in the history
Fix OPF prediction models
  • Loading branch information
scottpurdy authored Jun 7, 2017
2 parents c42c8bb + 9d75863 commit e6da897
Show file tree
Hide file tree
Showing 24 changed files with 88 additions and 2,005 deletions.
5 changes: 2 additions & 3 deletions docs/examples/network/complete-network-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ def runHotgym(numRecords):
numRecords = min(numRecords, dataSource.getDataRowCount())
network = createNetwork(dataSource)

# Set predicted field index. It needs to be the same index as the data source.
predictedIdx = dataSource.getFieldNames().index("consumption")
network.regions["sensor"].setParameter("predictedFieldIdx", predictedIdx)
# Set predicted field
network.regions["sensor"].setParameter("predictedField", "consumption")

# Enable learning for all regions.
network.regions["SP"].setParameter("learningMode", 1)
Expand Down
4 changes: 1 addition & 3 deletions docs/examples/network/example-set-predicted-field.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
predictedIdx = dataSource.getFieldNames().index("consumption")

network.regions["sensor"].setParameter("predictedFieldIdx", predictedIdx)
network.regions["sensor"].setParameter("predictedField", "consumption")
7 changes: 0 additions & 7 deletions docs/source/api/network/regions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ AnomalyLikelihoodRegion
:members:
:show-inheritance:

CLAClassifierRegion
^^^^^^^^^^^^^^^^^^^

.. autoclass:: nupic.regions.cla_classifier_region.CLAClassifierRegion
:members:
:show-inheritance:

KNNAnomalyClassifierRegion
^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion docs/source/contributing/cpp-style-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Filenames should not contain characters that could cause problems on different p

C++ header files should have the suffix ".hpp". C header files should have the suffix ".h".

C/C++ (`.h`, `.c`, `.hpp` and `.cpp`) and related SWIG (`.i`) file names should be **UpperCamelCase**. Initials and two-letter acronyms should be capitalized (e.g. **RegionIO.cpp**, **OSUnix.cpp**), longer acronyms treated as words (e.g. **FastClaClassifier.cpp**). A few non-code files (e.g. **README.md**, **cmake_install.cmake**) are uppercase or snake_case by standard convention.
C/C++ (`.h`, `.c`, `.hpp` and `.cpp`) and related SWIG (`.i`) file names should be **UpperCamelCase**. Initials and two-letter acronyms should be capitalized (e.g. **RegionIO.cpp**, **OSUnix.cpp**), longer acronyms treated as words (e.g. **SdrClassifier.cpp**). A few non-code files (e.g. **README.md**, **cmake_install.cmake**) are uppercase or snake_case by standard convention.

### Naming Conventions

Expand Down
5 changes: 1 addition & 4 deletions examples/network/hierarchy_network_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,7 @@ def createRecordSensor(network, name, dataSource):
sensorRegion.encoder = createEncoder()

# Specify which sub-encoder should be used for "actValueOut"
predictedFieldIdx = dataSource.getFieldNames().index("consumption")
network.regions[name].setParameter("predictedFieldIdx",
numpy.array([predictedFieldIdx],
dtype="uint32"))
network.regions[name].setParameter("predictedField", "consumption")

# Specify the dataSource as a file record stream instance
sensorRegion.dataSource = dataSource
Expand Down
13 changes: 6 additions & 7 deletions scripts/run_experiment_classifier_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
# ----------------------------------------------------------------------

"""This script is a command-line client of Online Prediction Framework (OPF).
It executes a single experiment and diffs the results for the CLAClassifier and
FastCLAClassifier.
It executes a single experiment and diffs the results for the SDRClassifier.
"""

import sys

from nupic.algorithms.cla_classifier_diff import CLAClassifierDiff
from nupic.algorithms.cla_classifier_factory import CLAClassifierFactory
from nupic.algorithms.sdr_classifier_diff import SDRClassifierDiff
from nupic.algorithms.sdr_classifier_factory import SDRClassifierFactory
from nupic.frameworks.opf.experiment_runner import (runExperiment,
initExperimentPrng)
from nupic.support import initLogging
Expand All @@ -41,12 +40,12 @@ def main():
# Initialize PRNGs
initExperimentPrng()

# Mock out the creation of the CLAClassifier.
# Mock out the creation of the SDRClassifier.
@staticmethod
def _mockCreate(*args, **kwargs):
kwargs.pop('implementation', None)
return CLAClassifierDiff(*args, **kwargs)
CLAClassifierFactory.create = _mockCreate
return SDRClassifierDiff(*args, **kwargs)
SDRClassifierFactory.create = _mockCreate

# Run it!
runExperiment(sys.argv[1:])
Expand Down
Loading

0 comments on commit e6da897

Please sign in to comment.