Coverage for src/causalspyne/edge_models.py: 69%
16 statements
« prev ^ index » next coverage.py v7.11.0, created at 2026-05-15 16:30 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2026-05-15 16:30 +0000
1import numpy as np
4class EdgeModelLinear():
5 def __init__(self, dag):
6 self._dag = dag
8 def run(self, ind_node, data_realization_parents):
9 """
10 data_realization_parents = data[:, list_parents_inds]
11 """
12 # Linear combination of parent nodes + Gaussian noise
13 weights = self._dag.get_weights_from_list_parents(ind_node)
14 bias = np.dot(data_realization_parents, weights)
15 return bias
18class EdgeModelIfElse():
19 def __init__(self, dag):
20 self._dag = dag
22 def run(self, ind_node, data_realization_parents):
23 """
24 data_realization_parents = data[:, list_parents_inds]
25 """
26 # Linear combination of parent nodes + Gaussian noise
27 weights = self._dag.get_weights_from_list_parents(ind_node)
28 weights_mod = np.where(data_realization_parents == 0,
29 -weights, weights)
30 bias = np.dot(data_realization_parents, weights_mod)
31 return bias