Exemple #1
0
 def test_should_be_1_for_same_sets_with_random_sets(self):
     fSet = generator.randomFuzzyList(100)
     self.assertEqual(1, mink.sim(fSet, fSet))
     fSet = generator.randomFuzzyList(1000)
     self.assertEqual(1, mink.sim(fSet, fSet))
     fSet = generator.randomFuzzyList(1000, 0.5, 0.7)
     self.assertEqual(1, mink.sim(fSet, fSet))
Exemple #2
0
 def test_with_really_big_random_sets_value_will_still_approach_one(self):
     first = generator.randomFuzzyList(100000)
     second = generator.randomFuzzyList(100000)
     sim = mink.sim(first, second)
     print "Similarity of random sets of length 100k should approach 1. Calculated value: %s" % sim
     self.assertAlmostEqual(1.0, sim, delta=0.01)
Exemple #3
0
 def test_with_completly_opposite_sets_few_elements(self):
     zeros = [0, 0, 0, 0]
     ones = [1, 1, 1, 1]
     self.assertEqual(0.5, mink.sim(zeros, ones))
Exemple #4
0
    def test_should_be_1_for_same_sets_with_static_sets(self):
        fSet = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        self.assertEqual(1, mink.sim(fSet, fSet))

        fSet = generator.randomFuzzyList(100)
        self.assertEqual(1, mink.sim(fSet, fSet))
Exemple #5
0
 def completly_different_sets(self, len, expected):
     zeros = generator.singletonFuzzyList(length=len, value=0)
     ones = generator.singletonFuzzyList(length=len, value=1)
     self.assertAlmostEqual(expected,
                            mink.sim(zeros, ones),
                            delta=0.0000001)