def setUp(self): from gPy.Examples import asia from gPy.Parameters import CPT from gPy.Models import JFR from agm2 import myBN cpts = [] for cpt in asia: if cpt.child() not in ('Smoking', 'Cancer', 'Bronchitis'): cpts.append(cpt) cpts.append( CPT((asia['Cancer'] * asia['Smoking']).sumout(['Smoking']), child='Cancer')) cpts.append( CPT((asia['Bronchitis'] * asia['Smoking']).sumout(['Smoking']), child='Bronchitis')) self.bn = myBN(cpts) jf = JFR(self.bn.copy(), modify=True) jf.calibrate() self.order = ('Cancer', 'Bronchitis', 'TbOrCa', 'XRay', 'VisitAsia', 'Tuberculosis', 'Dyspnea') self.margs = [] for v in self.order: # these checked to be correct with Netica self.margs.append(jf.var_marginal(v))
def calibration_demo(width=400,height=300, scrolled_width=40000,scrolled_height=40000, xscroll=2000,yscroll=1000,**config): """Demo of join tree calibration""" from gPy.Models import JFR from Tkinter import Tk from gPy.Utils import scrolled_frame root=scrolled_frame(Tk(),width=scrolled_width,height=scrolled_height, xscroll=xscroll,yscroll=yscroll) jfr = JFR(asia.copy(),modify=True, elimination_order=['VisitAsia','Tuberculosis','Smoking','Cancer', 'TbOrCa','XRay','Bronchitis','Dyspnea']) jfr.gui_calibrate(root) root.mainloop()
def setUp(self): from gPy.Examples import asia from gPy.Parameters import CPT from gPy.Models import JFR from agm2 import myBN cpts = [] for cpt in asia: if cpt.child() not in ("Smoking", "Cancer", "Bronchitis"): cpts.append(cpt) cpts.append(CPT((asia["Cancer"] * asia["Smoking"]).sumout(["Smoking"]), child="Cancer")) cpts.append(CPT((asia["Bronchitis"] * asia["Smoking"]).sumout(["Smoking"]), child="Bronchitis")) self.bn = myBN(cpts) jf = JFR(self.bn.copy(), modify=True) jf.calibrate() self.order = ("Cancer", "Bronchitis", "TbOrCa", "XRay", "VisitAsia", "Tuberculosis", "Dyspnea") self.margs = [] for v in self.order: # these checked to be correct with Netica self.margs.append(jf.var_marginal(v))
def setUp(self): jf = JFR(pedigree.copy(), modify=True) jf.calibrate() self.jf = jf self.g1 = [0.2, 0.3, 0.2, 0.1, 0.1, 0.1] self.g12 = [0.2025, 0.27, 0.225, 0.09, 0.15, 0.0625]
def setUp(self): jf = JFR(pedigree.copy(),modify=True) jf.calibrate() self.jf = jf self.g1 = [0.2, 0.3, 0.2, 0.1, 0.1, 0.1] self.g12 = [0.2025, 0.27, 0.225, 0.09, 0.15, 0.0625]