Changeset 10273:8840ec08b246 in orange
- Timestamp:
- 02/17/12 13:21:30 (15 months ago)
- Branch:
- default
- Location:
- Orange
- Files:
-
- 2 edited
-
misc/testing.py (modified) (2 diffs)
-
testing/unit/tests/test_association.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Orange/misc/testing.py
r10247 r10273 72 72 """ 73 73 from __future__ import absolute_import 74 import unittest 74 try: 75 import unittest2 as unittest 76 except: 77 import unittest 75 78 import os, sys 76 79 from functools import wraps … … 503 506 with member_set(self.distance_constructor, "ignore_class", True): 504 507 mat = distance_matrix(dataset, self.distance_constructor) 505 508 506 509 self.assertIsInstance(mat, Orange.misc.SymMatrix) 507 510 self.assertEqual(mat.dim, len(dataset)) 508 511 509 512 m = numpy.array(list(mat)) 510 513 self.assertTrue((m >= 0.0).all()) -
Orange/testing/unit/tests/test_association.py
r9979 r10273 3 3 from Orange.misc import testing 4 4 from Orange.misc.testing import test_on_data, datasets_driven 5 import unittest 5 try: 6 import unittest2 as unittest 7 except: 8 import unittest 6 9 import pickle 7 10 … … 12 15 if self.inducer.store_examples and rules: 13 16 self.assertIsNotNone(rules[0].examples) 14 17 15 18 self.assertLessEqual(len(rules), self.inducer.max_item_sets) 16 19 for r in rules: … … 24 27 self.assertAlmostEqual(r.lift, r.n_examples * r.n_applies_both / (r.n_applies_left * r.n_applies_right), places=3) 25 28 # self.assertAlmostEqual(r.leverage, (r.n_examples * r.n_applies_both - r.n_applies_left * r.n_applies_right) / 100.0) 26 29 27 30 itemsets = self.inducer.get_itemsets(table) 28 31 self.rules = rules … … 37 40 self.assertEqual(r1.support, r2.support) 38 41 self.assertEqual(r2.support, r3.support) 39 42 40 43 self.assertEqual(r1.confidence, r2.confidence) 41 44 self.assertEqual(r2.confidence, r3.confidence) 42 45 43 46 self.assertEqual(r1.coverage, r2.coverage) 44 47 self.assertEqual(r2.coverage, r3.coverage) 45 48 46 49 self.assertEqual(r1.strength, r2.strength) 47 50 self.assertEqual(r2.strength, r3.strength) 48 51 49 52 for inst in table: 50 53 self.assertEqual(r1.applies_left(inst), r2.applies_left(inst)) 51 54 self.assertEqual(r2.applies_left(inst), r3.applies_left(inst)) 52 55 53 56 self.assertEqual(r1.applies_right(inst), r2.applies_right(inst)) 54 57 self.assertEqual(r2.applies_right(inst), r3.applies_right(inst)) 55 58 56 59 self.assertEqual(r1.applies_both(inst), r2.applies_both(inst)) 57 60 self.assertEqual(r2.applies_both(inst), r3.applies_both(inst)) 58 59 61 62 60 63 @datasets_driven(datasets=["inquisition.basket"]) 61 64 class TestSparseInducer(unittest.TestCase): … … 63 66 self.inducer = associate.AssociationRulesSparseInducer(support=0.5, 64 67 store_examples=True, max_item_sets=2000) 65 68 66 69 @test_on_data 67 70 def test_inducer_on(self, table): … … 72 75 def test_pickling_on(self, table): 73 76 test_pickling_on(self, table) 74 77 75 78 76 79 @datasets_driven(datasets=["lenses", "monks-1"]) … … 80 83 confidence=0.5, store_examples=True, 81 84 max_item_sets=2000) 82 85 83 86 @test_on_data 84 87 def test_inducer_on(self, table): 85 88 test_inducer_on(self, table) 86 89 87 90 @test_on_data 88 91 def test_pickling_on(self, table): 89 92 test_pickling_on(self, table) 90 91 93 94 92 95 @datasets_driven(datasets=["lenses", "monks-1"]) 93 96 class TestInducerClassification(unittest.TestCase): … … 97 100 max_item_sets=2000, 98 101 classification_rules=True) 99 102 100 103 @test_on_data 101 104 def test_inducer_on(self, table): 102 105 test_inducer_on(self, table) 103 106 104 107 @test_on_data 105 108 def test_pickling_on(self, table): 106 109 test_pickling_on(self, table) 107 110 108 111 109 112 if __name__ is "__main__": 110 113 unittest.main() 111 114 112 115
Note: See TracChangeset
for help on using the changeset viewer.
