def create(self, network_factory: bayesianpy.network.NetworkFactory): network = self._template.create(network_factory) for i, var in enumerate(self._discretised_variables.columns.tolist()): node = builder.get_node(network, str(var)) if node is not None: links_from = [ link.getFrom() for link in node.getLinks() if link.getFrom().getName() != var ] links_to = [ link.getTo() for link in node.getLinks() if link.getTo().getName() != var ] network.getNodes().remove(node) for node in builder.create_discretised_variables( network, self._continuous, self._discretised_variables.columns.tolist(), bin_count=self._default_bin_count, mode=self._mode, zero_crossing=self._zero_crossing, defined_bins=self._bins): if node is not None: for l in links_from: builder.create_link(network, l, node) for l in links_to: builder.create_link(network, node, l) return network
def create(self, network_factory: bayesianpy.network.NetworkFactory): network = self._template.create(network_factory) cluster = builder.create_cluster_variable(network, self._latent_states) for node in bayesianpy.network.get_nodes(network): if node == cluster: continue builder.create_link(network, cluster, node) if self._target_nodes is not None: for target_node in self._target_nodes: target = builder.get_node(network, target_node) builder.delete_links_from(network, target) if self._remove_target_node: bayesianpy.network.remove_node(network, self._target_nodes) return network