MCPcopy Index your code
hub / github.com/clips/pattern / test_information_gain

Method test_information_gain

test/test_vector.py:556–569  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

554 print "pattern.vector.Model.filter()"
555
556 def test_information_gain(self):
557 # Assert information gain weights.
558 # Example from http://www.comp.lancs.ac.uk/~kc/Lecturing/csc355/DecisionTrees_given.pdf
559 v = vector.Model([
560 vector.Document({"wind":1}, type=False),
561 vector.Document({"wind":0}, type=True),
562 vector.Document({"wind":0}, type=True),
563 vector.Document({"wind":0}, type=True),
564 vector.Document({"wind":1}, type=True),
565 vector.Document({"wind":1}, type=False),
566 vector.Document({"wind":1}, type=False)], weight=vector.TF
567 )
568 self.assertAlmostEqual(v.information_gain("wind"), 0.52, places=2)
569 print "patten.vector.Model.information_gain()"
570
571#---------------------------------------------------------------------------------------------------
572

Callers

nothing calls this directly

Calls 1

information_gainMethod · 0.95

Tested by

no test coverage detected