Beispiel #1
0
 def discrete_parameter_estimation_cb(self, req):
     skel = U.graph_skeleton_from_ros(req.graph)
     skel.toporder()
     data = U.graph_states_dict_from_ros(req.states)
     res = self.learner.discrete_mle_estimateparams(skel, data)
     return DiscreteParameterEstimationResponse(
         U.discrete_nodes_to_ros(res.Vdata))
 def test_query(self):
     teacher_nd = NodeData()
     teacher_nd.load(self.teacher_data_path)
     req = DiscreteQueryRequest()
     req.nodes = U.discrete_nodes_to_ros(teacher_nd.Vdata)
     req.evidence = [DiscreteNodeState("Letter", "weak")]
     req.query = ["Grade"]
     res = self.query(req)
     self.assertEqual(len(res.nodes), 1)
     n = res.nodes[0]
     self.assertEqual(n.name, "Grade")
     self.assertListEqual(['A', 'B', 'C'], n.outcomes)
 def test_query(self):
     teacher_nd = NodeData()
     teacher_nd.load(self.teacher_data_path)
     req = DiscreteQueryRequest()
     req.nodes = U.discrete_nodes_to_ros(teacher_nd.Vdata)
     req.evidence = [DiscreteNodeState("Letter", "weak")]
     req.query = ["Grade"]
     res = self.query(req)
     self.assertEqual(len(res.nodes), 1)
     n = res.nodes[0]
     self.assertEqual(n.name, "Grade")
     self.assertListEqual(['A','B','C'], n.outcomes)