Skip to content

Commit

Permalink
updating pruning func for varlingam for faster processing
Browse files Browse the repository at this point in the history
Signed-off-by: Sven <[email protected]>
  • Loading branch information
Sven committed Apr 4, 2024
1 parent e1e2a6f commit 0ac09dc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions causallearn/search/FCMBased/lingam/var_lingam.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,14 @@ def _pruning(self, X, B_taus, causal_order):
obj = np.zeros((len(blocks)))
exp = np.zeros(
(len(blocks), causal_order_no + n_features * self._lags))
for j, block in enumerate(blocks):
obj[j] = block[0][i]
exp[j:] = np.concatenate(
[block[0][ancestor_indexes].flatten(), block[1:][:].flatten()], axis=0)

# Create 3D array to hold flattened ancestor indices for each block
ancestor_indexes_flat = blocks[:, 0, ancestor_indexes].reshape(len(blocks), -1)
# Fill obj using advanced indexing
obj[:] = blocks[:, 0, i]
# Fill exp using advanced indexing
exp[:, :causal_order_no] = ancestor_indexes_flat
exp[:, causal_order_no:] = blocks[:, 1:].reshape(len(blocks), -1)

# adaptive lasso
gamma = 1.0
Expand Down

0 comments on commit 0ac09dc

Please sign in to comment.