(self)
| 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 |
nothing calls this directly
no test coverage detected