# along with this program. If not, see http://www.gnu.org/licenses. # # http://numenta.org/licenses/ # ---------------------------------------------------------------------- from random import * import numpy import pdb import cPickle import bz2 import sys import pylab import nupic.bindings.algorithms as algo from nupic.bindings.math import GetNumpyDataType type = GetNumpyDataType('NTA_Real') type = 'float32' #-------------------------------------------------------------------------------- # Simple use case #-------------------------------------------------------------------------------- def simple(): print "Simple" numpy.random.seed(42) n_dims = 2 n_class = 4 size = 200 labels = numpy.random.random_integers(0, n_class - 1, size) samples = numpy.zeros((size, n_dims), dtype=type)
"""Unit tests for the SVM classifiers.""" import cPickle as pickle import hashlib import os import numpy as np import unittest2 as unittest from nupic.bindings.algorithms import svm_dense, svm_01 from nupic.bindings.math import GetNumpyDataType _SEED = 42 _RGEN = np.random.RandomState(_SEED) # 32 bits for sse _DTYPE = GetNumpyDataType("NTA_Real") class SVMTest(unittest.TestCase): """Unit tests for the SVM classifier.""" def testGetstateSetstate(self): nDims = 32 # need multiple of 8, because of sse nClass = 4 size = 20 labels = _RGEN.random_integers(0, nClass - 1, size) samples = np.zeros((size, nDims), dtype=_DTYPE) centers = np.array([[0, 0], [0, 1], [1, 0], [1, 1]]) for i in range(0, size): t = 6.28 * _RGEN.random_sample()
# # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses. # # http://numenta.org/licenses/ # ---------------------------------------------------------------------- raise Exception("XERROR mcmc not available") import copy import time import numpy from nupic.support.pythonics import Accessor from nupic.bindings.math import CMultiArgMax, GetNumpyDataType realDType = GetNumpyDataType("NTA_Real") class MCMCState(object): def __init__(self, values, logPrior, logLikelihood, postTime, **keywds): self.values = values self.logPrior = logPrior self.logLikelihood = logLikelihood self.info = keywds self.time = postTime def __str__(self): return ("<state logPrior='%f' logLikelihood='%f'>" % (self.logPrior, self.logLikelihood)) + str(self.values) + "</state>" def __repr__(self): return ("<state logPrior='%f' logLikelihood='%f'>" % (self.logPrior, self.logLikelihood)) + repr(self.values) + "</state>"