def posterior_predictive(self, target_names=None, data={}): if self.inference_method is None: raise RuntimeError( "posterior_preductive cannot be used before using the fit function." ) # only non-observed variables can be in target_names if target_names is None: target_names = [ name for name in self.vars.keys() if name in self.observed_vars ] else: if any(var not in self.observed_vars for var in target_names): raise ValueError( "target_names must correspond to observed variables during the inference: \ {}".format(self.observed_vars)) # posterior_predictive uses pmodel variables, but global hidden (parameters) intercepted with qmodel variables. return Query( self.inference_method.expanded_variables["p"], target_names, data, enable_interceptor_variables=( # just interested in intercept the global parameters, not the local hidden self.inference_method.get_interceptable_condition_variables() [0], None))
def posterior_predictive(self, target_names=None, data={}): # posterior_predictive uses pmodel variables, but global hidden (parameters) intercepted with qmodel variables. return Query( self.expanded_variables["p"], target_names, data, # just interested in intercept the global parameters, not the local hidden enable_interceptor_variables=(self.enable_interceptor_global, None))
def posterior_predictive(self, target_names=None, data={}): # posterior_predictive uses pmodel variables, but global hidden (parameters) intercepted with qmodel variables. expanded_data = { **data, **(util.runtime.try_run({ k: v.sample() for k, v in self.states.items() if k not in data })) } return Query(self.pmodel.vars, target_names, expanded_data)
def prior(self, target_names=None, data={}, size_datamodel=1): if size_datamodel > 1: variables, _ = self.expand_model(size_datamodel) elif size_datamodel == 1: variables = self.vars else: raise ValueError( "size_datamodel must be greater than 0 but it is {}".format( size_datamodel)) return Query(variables, target_names, data)
def posterior(self, target_names=None, data={}): if self.inference_method is None: raise RuntimeError( "posterior cannot be used before using the fit function.") # only non-observed variables can be in target_names if target_names is None: target_names = [ name for name in self.vars.keys() if name not in self.observed_vars ] else: if any(var in self.observed_vars for var in target_names): raise ValueError( "target_names must correspond to not observed variables during the inference: \ {}".format([ v for v in self.vars.keys() if v not in self.observed_vars ])) return Query(self.inference_method.expanded_variables["q"], target_names, data)
def posterior(self, target_names=None, data={}): return Query(self.states, target_names, data)
def posterior(self, target_names=None, data={}): return Query(self.expanded_variables["q"], target_names, data)