Exemplo n.º 1
0
 def test_classifier_error(self):
     cInst = 100
     listInst = build_instance_generator()(cInst)
     ix = random.randint(0,cInst)
     rslt = dtree.EvaluationResult(listInst[:ix], listInst[ix:], None)
     self.assertAlmostEqual(float(cInst-ix)/float(cInst),
                            dtree.classifier_error(rslt))
Exemplo n.º 2
0
 def test_weight_corrrect_incorrect(self):
     def make_list(cLen):
         listI = []
         dblSum = 0.0
         for _ in xrange(cLen):
             dbl = math.exp(-random.random() - 0.1) * 10.0
             listI.append(dtree.Instance([],randbool(),dbl))
             dblSum += dbl
         return listI,dblSum
     listInstCorrect,dblCorrect = make_list(random.randint(0,10))
     listInstIncorrect,dblIncorrect = make_list(random.randint(0,10))
     rslt = dtree.EvaluationResult(listInstCorrect, listInstIncorrect,None)
     dblC,dblI = dtree.weight_correct_incorrect(rslt)
     self.assertAlmostEqual(dblCorrect,dblC)
     self.assertAlmostEqual(dblIncorrect,dblI)