def go(self, obs, a, b, arr, ci): # manipulate a and b iic = InterventionalICPattern({obs: ci[obs], a | b: ci[a | b]}) self.assertEquals(iic.lines(), [arr[0]]) xs = [x for x, y in arr if y == 'c' or x == 'c'] if xs: self.assertEquals(iic.arrows(), [arr[1]]) else: self.assertEquals(iic.arrows(), [])
def go(self,obs,a,b,arr,ci): # manipulate a and b iic = InterventionalICPattern({obs:ci[obs], a|b:ci[a|b]}) self.assertEquals(iic.lines(), [arr[0]]) xs = [x for x, y in arr if y == 'c' or x == 'c'] if xs: self.assertEquals(iic.arrows(),[arr[1]]) else: self.assertEquals(iic.arrows(),[])
def tryModel(self, model): model_do = CBN.from_bn(model.copy(copy_domain=True)) # perform every interventional query ci = {} for q in model_do.good_interventions(): # generate the model model_do = CBN.from_bn(model.copy(copy_domain=True)) model_do.intervene(q) ci[frozenset(q.keys())] = GraphCI(model_do.adg()) iic = InterventionalICPattern(ci) self.assertEquals(iic.lines(), []) self.assertEquals(iic.orient(), model.adg())
def tryModel(self, model): # perform every interventional query ci = {} for xs in powerset(model.variables()): # build the intervention q q = {} for x in xs: q[x] = frozenset([set(model.values(x)).pop()]) # generate the model model_do = CBN.from_bn(model.copy(copy_domain=True)) model_do.intervene(q) ci[frozenset(q.keys())] = GraphCI(model_do.adg()) iic = InterventionalICPattern(ci) self.assertEquals(iic.lines(), []) self.assertEquals(iic.orient(), model.adg())
def go(self, obs, a, b, arr, ci): # manipulate b iic = InterventionalICPattern({obs: ci[obs], b: ci[b]}) self.assertEquals(iic.lines(), []) self.assertEquals(iic.arrows(), arr)
def go(self, obs, a, b, arr, ci): # observational iic = InterventionalICPattern({obs: ci[obs]}) self.assertEquals(iic.arrows(), []) self.assertEquals(iic.lines(), arr)
def go(self,obs,a,b,arr,ci): # manipulate b iic = InterventionalICPattern({obs:ci[obs], b:ci[b]}) self.assertEquals(iic.lines(), []) self.assertEquals(iic.arrows(), arr)
def go(self,obs,a,b,arr,ci): # observational iic = InterventionalICPattern({obs:ci[obs]}) self.assertEquals(iic.arrows(), []) self.assertEquals(iic.lines(), arr)