How to use the simpleai.machine_learning.VectorDataClassificationProblem function in simpleai

To help you get started, we’ve selected a few simpleai examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github simpleai-team / simpleai / tests / machine_learning / test_evaluation.py View on Github external
def my_setup(self, train):
        self.p = VectorDataClassificationProblem(train, 0)
        self.c = MockClassifier(train, self.p)
github simpleai-team / simpleai / tests / machine_learning / test_evaluation.py View on Github external
def setUp(self):
        self.p = VectorDataClassificationProblem(self.train, 0)
        self.c = MockClassifier(self.train, self.p)
github simpleai-team / simpleai / samples / machine_learning / iris.py View on Github external
def main():
    # line count
    N = 0
    for _ in open(IRIS_PATH):
        N += 1
    testindexes = set(random.sample(xrange(N), N / 10))

    dataset = IrisDataset(IRIS_PATH, lambda i: i not in testindexes)
    testset = IrisDataset(IRIS_PATH, lambda i: i in testindexes)
    problem = VectorDataClassificationProblem(dataset, dataset.target_index)
    # Distance without target
    problem.distance = lambda x, y: euclidean_vector_distance(x[:-1], y[:-1])

    classifiers = {
        "K-Nearest Neighbours": KNearestNeighbors,
        "Naive Bayes": NaiveBayes,
        "Decision Tree": DecisionTreeLearner_Queued,
    }

    print "Precision:\n"
    for name, method in classifiers.iteritems():
        classifier = method(dataset, problem)
        p = precision(classifier, testset)
        print "{:>20} = {:.2}".format(name, p)