def get_default_box( sm: StructureModel, node_states: Dict[str, list], lv_name: str, ) -> Dict[str, Tuple[pd.DataFrame, pd.DataFrame]]: """ Get boxes with min = 0 and max = 1 for all parameters. Args: sm: model structure node_states: node states lv_name: name of latent variable Returns: Dictionary with a tuple of two elements: the first being the lower value constraint and the second the maximum value constraint """ valid_node_set = set([lv_name] + list(sm.successors(lv_name))) boxes = {} for node in sm.nodes: if node in valid_node_set: cpd = EMSingleLatentVariable._initialise_node_cpd(node, node_states, sm) min_vals, max_vals = cpd.copy(), cpd.copy() min_vals.loc[:] = 0 max_vals.loc[:] = 1 boxes[node] = (min_vals, max_vals) return boxes
def get_default_priors( sm: StructureModel, node_states: Dict[str, list], lv_name: str, ) -> Dict[str, Tuple[pd.DataFrame, pd.DataFrame]]: """ The default dirichlet priors (zero values) Args: sm: model structure node_states: node states lv_name: name of latent variable Returns: Dictionary with pd dataframes initialized with zeros """ valid_node_set = set([lv_name] + list(sm.successors(lv_name))) return { node: EMSingleLatentVariable._initialise_node_cpd(node, node_states, sm) for node in sm.nodes if node in valid_node_set }