Ejemplo n.º 1
0
 def test_baddata(self):
     """inference should raise when input is bad"""  
     
     rs = ReferenceSet(dict(refA=0.5, refB=0.5), ids=["a", "b", "c"])
     rs.prep()        
     with self.assertRaises(Exception) as e:
         rs.inference(5)
Ejemplo n.º 2
0
    def test_scores_bad_input(self):
        """inference function should raise with bad input."""

        # model is empty
        rs = ReferenceSet(dict(refA=0.5, refB=0.5), ids=obo.ids())
        with self.assertRaises(Exception):
            rs.inference("refA")
Ejemplo n.º 3
0
 def test_between2(self):
     """inference when model equally similar to two refs"""  
     
     # let ref universe have two annotations
     rs = ReferenceSet(dict(refA=0.5, refB=0.5), ids=self.obo.ids(),
                       row_priors=self.obodefaults)
     rs.add(self.refA).add(self.refB)
     rs.learn_obo(self.obo)
     rs.prep()
     
     inf = rs.inference(self.y3model)
     self.assertAlmostEqual(inf["refA"], inf["refB"], msg="equally likely")        
Ejemplo n.º 4
0
 def test_between_refs_and_null(self):
     """inference when model is similar to two refs and a there is a null"""  
     
     # let ref universe have two annotations and one null
     rs = ReferenceSet(dict(null=0.8, refA=0.15, refB=0.15), 
                       ids=self.obo.ids(), row_priors=self.obodefaults)
     rs.add(self.refA).add(self.refB)        
     rs.learn_obo(self.obo)
     rs.prep()
     
     inf = rs.inference(self.y3model)            
     self.assertAlmostEqual(inf["refA"], inf["refB"], 
                            msg="equally likely")
Ejemplo n.º 5
0
 def test_model_nodata(self):
     """inference when references are unequal but model has no data"""  
     
     model = Representation(name="nodata")
     # let ref universe have two annotations and one null
     rs = ReferenceSet(dict(null=0.8, refA=0.1, refB=0.1), 
                       ids=self.obo.ids(), row_priors=self.obodefaults)
     rs.add(self.refA).add(self.refB)
     rs.learn_obo(self.obo)
     rs.prep()
     
     inf = rs.inference(model)             
     self.assertAlmostEqual(inf["refA"], inf["refB"], 
                            msg="equally likely")
Ejemplo n.º 6
0
 def test_difference_in_priors(self):
     """inference when model matches two references, 
     but have different priors"""  
     
     # let ref universe have two annotations and one null
     rs = ReferenceSet(dict(null=0.85, refA=0.05, refB=0.1), 
                       ids=self.obo.ids(), row_priors=self.obodefaults)
     rs.add(self.refA).add(self.refB)
     rs.learn_obo(self.obo)
     rs.prep()
     
     inf = rs.inference(self.y3model)             
     self.assertLess(inf["refA"], inf["refB"], 
                     msg="equal match, but A has weaker prior")
Ejemplo n.º 7
0
 def test_underflow(self):
     """attempt to get underflow in individual p."""  
     
     # let model have very sure values
     model = Representation(name="underflow")
     model.set("Y:007", 0.00001).set("Y:004", 1).set("Y:003", 1)
     # let ref universe have two annotations and one null
     refA = Representation(name="refA").set("Y:003", 1)        
     refB = Representation(name="refB").set("Y:003", 1)        
     rs = ReferenceSet(dict(null=0.98, refA=0.001, refB=0.001), 
                       ids=self.obo.ids())
     rs.add(refA).add(refB)
     rs.learn_obo(self.obo)
     rs.prep()        
             
     result = rs.inference(model, verbose=True)                 
     self.assertGreaterEqual(result["refA"], 0, 
                     msg="must always be a number, even if zero")        
     self.assertGreaterEqual(result["refB"], 0, 
                     msg="must always be a number, even if zero")
     self.assertGreaterEqual(result["refB"], 0, 
                     msg="must always be a number, even if zero")