Code snippets for page Classifier nodesΒΆ
Download classifiers.py
.
Browse the code snippet index.
# -*- coding: utf-8 -*-
# Generated by codesnippet sphinx extension on 2020-12-16
import mdp
import numpy as np
np.random.seed(0)
gc = mdp.nodes.GaussianClassifier()
gc.train(np.random.random((50, 3)), +1)
gc.train(np.random.random((50, 3)) - 0.8, -1)
gc.train(np.random.random((50, 3)), [+1] * 50)
test_data = np.array([[0.1, 0.2, 0.1], [-0.1, -0.2, -0.1]])
gc.label(test_data)
# Expected:
## [1, -1]
prob = gc.prob(test_data)
print prob[0][-1], prob[0][+1]
# Expected:
## 0.188737388144 0.811262611856
print prob[1][-1], prob[1][+1]
# Expected:
## 0.992454101588 0.00754589841187
gc.rank(test_data)
# Expected:
## [[1, -1], [-1, 1]]