-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_FPCMCI.py
40 lines (33 loc) · 1.32 KB
/
main_FPCMCI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from tigramite.independence_tests.gpdc import GPDC
from causalflow.CPrinter import CPLevel
from causalflow.causal_discovery.FPCMCI import FPCMCI
from causalflow.preprocessing.data import Data
from causalflow.selection_methods.TE import TE, TEestimator
from causalflow.basics.constants import LabelType
import numpy as np
if __name__ == '__main__':
f_alpha = 0.1
pcmci_alpha = 0.05
min_lag = 0
max_lag = 2
np.random.seed(1)
nsample = 500
nfeature = 5
d = np.random.random(size = (nsample, nfeature))
for t in range(max_lag, nsample):
d[t, 1] += 0.5 * d[t-1, 0]**2
d[t, 2] += 0.3 * d[t-1, 0] * 0.75 * d[t-2, 1] - 2.5
d[t, 3] += 0.7 * d[t-1, 3] * d[t-2, 4]
df = Data(d, vars = ['X_0', 'X_1', 'X_2', 'X_3', 'X_4'])
fpcmci = FPCMCI(df,
f_alpha = f_alpha,
alpha = pcmci_alpha,
min_lag = min_lag,
max_lag = max_lag,
sel_method = TE(TEestimator.Gaussian),
val_condtest = GPDC(significance = 'analytic', gp_params = None),
verbosity = CPLevel.DEBUG,
neglect_only_autodep = True)
cm = fpcmci.run()
fpcmci.dag(label_type = LabelType.Lag, node_layout = 'dot')
fpcmci.timeseries_dag()