class TestBaselineLearner(TestCase): labels = Matrix() labels._load_arff("test/cm1_req.arff") l = BaselineLearner() def test_train(self): self.l.train(Matrix(), self.labels) self.assertAlmostEqual(self.l.labels[0], 1.426966, places=4) def test_predict(self): self.l.train(Matrix(), self.labels) labels = [] self.l.predict([], labels) self.assertListEqual(self.l.labels, labels)
def get_learner(self, model): """ Get an instance of a learner for the given model name. To use toolkitPython as external package, you can extend this class (MLSystemManager) with your own custom class located outside of this package, and override this method to return your custom learners. :type model: str :rtype: SupervisedLearner """ modelmap = { "baseline": BaselineLearner(), "perceptron": PerceptronLearner(), # "neuralnet": NeuralNetLearner(), # "decisiontree": DecisionTreeLearner(), # "knn": InstanceBasedLearner() } if model in modelmap: return modelmap[model] else: raise Exception("Unrecognized model: {}".format(model))