Пример #1
0
 def test_classifiers(self):
     """classifiers should return all the 1D classifiers of samples"""
     first = array([2,1,5,3,5])
     second = array([2,5,5,4,6,7])
     result = classifiers(first, second)
     self.assertEqual(len(result), 6)
     exp = [(1,False,0,4,1,6),(3,False,1,3,2,5),(4,False,1,2,3,5),\
            (5,False,2,2,3,4),(9,False,4,0,5,2),(10,False,5,0,5,1)]
     self.assertEqual(result, exp)
     #should work in reverse
     result = classifiers(second, first)
     exp = [(1,True,0,4,1,6),(3,True,1,3,2,5),(4,True,1,2,3,5),\
            (5,True,2,2,3,4),(9,True,4,0,5,2),(10,True,5,0,5,1)]
Пример #2
0
 def test_minimize_error_rate(self):
     """minimize_error_rate should return correct classifier"""
     #should be same as error count on example used above
     first = array([2,1,5,3,5])
     second = array([2,5,5,4,6,7])
     c = classifiers(first, second)
     exp = (4,False,1,2,3,5)
     self.assertEqual(minimize_error_rate(c), exp)
     #here's a case where they should differ
     first = array([2,3,11,5])
     second = array([1,4,6,7,8,9,10])
     c = classifiers(first, second)
     self.assertEqual(minimize_error_count(c), (3,False,1,2,2,6))
     self.assertEqual(minimize_error_rate(c), (5,False,2,1,3,5))
Пример #3
0
 def test_minimize_error_count(self):
     """minimize_error_count should return correct classifier"""
     first = array([2,1,5,3,5])
     second = array([2,5,5,4,6,7])
     c = classifiers(first, second)
     exp = (4,False,1,2,3,5)
     self.assertEqual(minimize_error_count(c), exp)