How to use the simpleai.machine_learning.metrics.OnlineEntropy 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_metrics.py View on Github external
def test_full_gain(self):
        target = lambda x: x % 7
        gain = OnlineInformationGain(target, target)
        entropy = OnlineEntropy(target)
        for i in xrange(50):
            gain.add(i)
            entropy.add(i)
        self.assertEqual(gain.get_gain(), entropy.get_entropy())
        self.assertGreaterEqual(gain.get_gain(), 0)
github simpleai-team / simpleai / tests / machine_learning / test_metrics.py View on Github external
def test_valid_values(self):
        entropy = OnlineEntropy(lambda x: x % 10)
        for i in xrange(150):
            entropy.add(i)
        self.assertGreaterEqual(entropy.get_entropy(), 0.0)
github simpleai-team / simpleai / tests / machine_learning / test_metrics.py View on Github external
def test_starts_in_zero(self):
        entropy = OnlineEntropy(lambda x: None)
        self.assertEqual(entropy.get_entropy(), 0)
github simpleai-team / simpleai / simpleai / machine_learning / metrics.py View on Github external
def __init__(self, attribute, target):
        self.attribute = attribute
        self.H = OnlineEntropy(target)
        self.G = defaultdict(lambda: OnlineEntropy(target))