class HTMClassifierTest(unittest.TestCase): def setUp(self): with open(_NTWK_CONFIG, "rb") as jsonFile: self.network_config = simplejson.load(jsonFile) self.classifier = HTMClassifier(self.network_config, _TRAINING_DATA, _CATEGORIES) self.classifier.initialize() def testTrainingAccuracy(self): partitions = generateNetworkPartitions(self.network_config, _TRAIN_SET_SIZE) training_accuracy = self.classifier.train(_TRAIN_SET_SIZE, partitions) self.assertEqual(training_accuracy, 94.75, "classification accuracy is incorrect") def testClassificationAccuracy(self): mu = 7 tag = "middle" result = self.classifier.classify(input_data=mu, target=tag, learning_is_on=True) print "classification_result: %s" % result
def setUp(self): with open(_NTWK_CONFIG, "rb") as jsonFile: self.network_config = simplejson.load(jsonFile) self.classifier = HTMClassifier(self.network_config, _TRAINING_DATA, _CATEGORIES) self.classifier.initialize()