Causal Discovery
This module provides the CausalDiscoveryMethod class.
Classes
CausalDiscoveryMethod: abstract class used by all the causal discovery algorithms.
CausalDiscoveryMethod
Bases: ABC
CausalDiscoveryMethod class.
CausalDiscoveryMethod is an abstract causal discovery method for large-scale time series datasets.
Source code in causalflow/causal_discovery/CausalDiscoveryMethod.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
__init__(data, min_lag, max_lag, verbosity, alpha=0.05, resfolder=None, neglect_only_autodep=False, clean_cls=True)
Class contructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Data
|
data to analyse. |
required |
min_lag |
int
|
minimum time lag. |
required |
max_lag |
int
|
maximum time lag. |
required |
verbosity |
CPLevel
|
verbosity level. |
required |
alpha |
float
|
significance level. Defaults to 0.05. |
0.05
|
resfolder |
string
|
result folder to create. Defaults to None. |
None
|
neglect_only_autodep |
bool
|
Bit for neglecting variables with only autodependency. Defaults to False. |
False
|
clean_cls |
bool
|
Clean console bit. Default to True. |
True
|
Source code in causalflow/causal_discovery/CausalDiscoveryMethod.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
load(res_path)
Load previously estimated result .
Parameters:
Name | Type | Description | Default |
---|---|---|---|
res_path |
str
|
pickle file path. |
required |
Source code in causalflow/causal_discovery/CausalDiscoveryMethod.py
78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
run()
abstractmethod
Run causal discovery method.
Returns:
Name | Type | Description |
---|---|---|
DAG |
DAG
|
causal model. |
Source code in causalflow/causal_discovery/CausalDiscoveryMethod.py
67 68 69 70 71 72 73 74 75 |
|
save()
Save causal discovery result as pickle file if resfolder is set.
Source code in causalflow/causal_discovery/CausalDiscoveryMethod.py
93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
This module provides the DYNOTEARS class.
Classes
DYNOTEARS: class containing the DYNOTEARS causal discovery algorithm.
DYNOTEARS
Bases: CausalDiscoveryMethod
DYNOTEARS causal discovery method.
Source code in causalflow/causal_discovery/baseline/DYNOTEARS.py
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
__init__(data, min_lag, max_lag, verbosity, alpha=0.05, resfolder=None, neglect_only_autodep=False, clean_cls=True)
Class constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Data
|
data to analyse. |
required |
min_lag |
int
|
minimum time lag. |
required |
max_lag |
int
|
maximum time lag. |
required |
verbosity |
CPLevel
|
verbosity level. |
required |
alpha |
float
|
PCMCI significance level. Defaults to 0.05. |
0.05
|
resfolder |
string
|
result folder to create. Defaults to None. |
None
|
neglect_only_autodep |
bool
|
Bit for neglecting variables with only autodependency. Defaults to False. |
False
|
clean_cls |
bool
|
Clean console bit. Default to True. |
True
|
Source code in causalflow/causal_discovery/baseline/DYNOTEARS.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
run()
Run DYNOTEARS algorithm.
Returns:
Name | Type | Description |
---|---|---|
DAG |
DAG
|
causal discovery result. |
Source code in causalflow/causal_discovery/baseline/DYNOTEARS.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
This module provides the LPCMCI class.
Classes
LPCMCI: class containing the LPCMCI causal discovery algorithm.
LPCMCI
Bases: CausalDiscoveryMethod
LPCMCI causal discovery method.
Source code in causalflow/causal_discovery/baseline/LPCMCI.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
__init__(data, min_lag, max_lag, val_condtest, verbosity, alpha=0.05, resfolder=None, neglect_only_autodep=False, clean_cls=True)
Class constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Data
|
data to analyse. |
required |
min_lag |
int
|
minimum time lag. |
required |
max_lag |
int
|
maximum time lag. |
required |
val_condtest |
CondIndTest
|
validation method. |
required |
verbosity |
CPLevel
|
verbosity level. |
required |
alpha |
float
|
PCMCI significance level. Defaults to 0.05. |
0.05
|
resfolder |
string
|
result folder to create. Defaults to None. |
None
|
neglect_only_autodep |
bool
|
Bit for neglecting variables with only autodependency. Defaults to False. |
False
|
clean_cls |
bool
|
Clean console bit. Default to True. |
True
|
Source code in causalflow/causal_discovery/baseline/LPCMCI.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
run(link_assumptions=None)
Run causal discovery algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
link_assumptions |
dict
|
prior knowledge on causal model links. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
DAG
|
estimated causal model. |
Source code in causalflow/causal_discovery/baseline/LPCMCI.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
This module provides the PCMCI class.
Classes
PCMCI: class containing the PCMCI causal discovery algorithm.
PCMCI
Bases: CausalDiscoveryMethod
PCMCI causal discovery method.
Source code in causalflow/causal_discovery/baseline/PCMCI.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
__init__(data, min_lag, max_lag, val_condtest, verbosity, pc_alpha=0.05, alpha=0.05, resfolder=None, neglect_only_autodep=False, clean_cls=True)
Class constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Data
|
data to analyse. |
required |
min_lag |
int
|
minimum time lag. |
required |
max_lag |
int
|
maximum time lag. |
required |
val_condtest |
CondIndTest
|
validation method. |
required |
verbosity |
CPLevel
|
verbosity level. |
required |
pc_alpha |
float
|
PC significance level. Defaults to 0.05. |
0.05
|
alpha |
float
|
PCMCI significance level. Defaults to 0.05. |
0.05
|
resfolder |
string
|
result folder to create. Defaults to None. |
None
|
neglect_only_autodep |
bool
|
Bit for neglecting variables with only autodependency. Defaults to False. |
False
|
clean_cls |
bool
|
Clean console bit. Default to True. |
True
|
Source code in causalflow/causal_discovery/baseline/PCMCI.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
run(link_assumptions=None)
Run causal discovery algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
link_assumptions |
dict
|
prior knowledge on causal model links. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
DAG
|
estimated causal model. |
Source code in causalflow/causal_discovery/baseline/PCMCI.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
This module provides the PCMCI+ class.
Classes
PCMCIplus: class containing the PCMCI+ causal discovery algorithm.
PCMCIplus
Bases: CausalDiscoveryMethod
PCMCI+ causal discovery method.
Source code in causalflow/causal_discovery/baseline/PCMCIplus.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
__init__(data, min_lag, max_lag, val_condtest, verbosity, alpha=0.05, resfolder=None, neglect_only_autodep=False, clean_cls=True)
Class constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Data
|
data to analyse. |
required |
min_lag |
int
|
minimum time lag. |
required |
max_lag |
int
|
maximum time lag. |
required |
val_condtest |
CondIndTest
|
validation method. |
required |
verbosity |
CPLevel
|
verbosity level. |
required |
alpha |
float
|
significance level. Defaults to 0.05. |
0.05
|
resfolder |
string
|
result folder to create. Defaults to None. |
None
|
neglect_only_autodep |
bool
|
Bit for neglecting variables with only autodependency. Defaults to False. |
False
|
clean_cls |
bool
|
Clean console bit. Default to True. |
True
|
Source code in causalflow/causal_discovery/baseline/PCMCIplus.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
run(link_assumptions=None)
Run causal discovery algorithm.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
link_assumptions |
dict
|
prior knowledge on causal model links. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
DAG
|
estimated causal model. |
Source code in causalflow/causal_discovery/baseline/PCMCIplus.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
This module provides the TCDF class.
Classes
TCDF: class containing the TCDF causal discovery algorithm.
TCDF
Bases: CausalDiscoveryMethod
TCDF causal discovery method.
Source code in causalflow/causal_discovery/baseline/TCDF.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
__init__(data, min_lag, max_lag, verbosity, resfolder=None, neglect_only_autodep=False, clean_cls=True)
Class constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Data
|
data to analyse. |
required |
min_lag |
int
|
minimum time lag. |
required |
max_lag |
int
|
maximum time lag. |
required |
verbosity |
CPLevel
|
verbosity level. |
required |
resfolder |
string
|
result folder to create. Defaults to None. |
None
|
neglect_only_autodep |
bool
|
Bit for neglecting variables with only autodependency. Defaults to False. |
False
|
clean_cls |
bool
|
Clean console bit. Default to True. |
True
|
Source code in causalflow/causal_discovery/baseline/TCDF.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
run(epochs=1000, kernel_size=4, dilation_coefficient=4, hidden_layers=0, learning_rate=0.01, cuda=False)
Run causal discovery algorithm.
Returns:
Type | Description |
---|---|
DAG
|
estimated causal model. |
Source code in causalflow/causal_discovery/baseline/TCDF.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
This module provides the tsFCI class.
Classes
tsFCI: class containing the tsFCI causal discovery algorithm.
tsFCI
Bases: CausalDiscoveryMethod
tsFCI causal discovery method.
Source code in causalflow/causal_discovery/baseline/tsFCI.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
__init__(data, min_lag, max_lag, verbosity, alpha=0.05, resfolder=None, neglect_only_autodep=False, clean_cls=True)
Class constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Data
|
data to analyse. |
required |
min_lag |
int
|
minimum time lag. |
required |
max_lag |
int
|
maximum time lag. |
required |
verbosity |
CPLevel
|
verbosity level. |
required |
alpha |
float
|
PCMCI significance level. Defaults to 0.05. |
0.05
|
resfolder |
string
|
result folder to create. Defaults to None. |
None
|
neglect_only_autodep |
bool
|
Bit for neglecting variables with only autodependency. Defaults to False. |
False
|
clean_cls |
bool
|
Clean console bit. Default to True. |
True
|
Source code in causalflow/causal_discovery/baseline/tsFCI.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
run()
Run causal discovery algorithm.
Returns:
Type | Description |
---|---|
DAG
|
estimated causal model. |
Source code in causalflow/causal_discovery/baseline/tsFCI.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
ts_fci_dataframe_to_dict(df, names, nlags)
Convert tsFCI result into a dict for _to_DAG.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
graph. |
required |
names |
list[str]
|
variables' name. |
required |
nlags |
int
|
max time lag. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
dict graph. |
Source code in causalflow/causal_discovery/baseline/tsFCI.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
This module provides the VarLiNGAM class.
Classes
VarLiNGAM: class containing the VarLiNGAM causal discovery algorithm.
VarLiNGAM
Bases: CausalDiscoveryMethod
VarLiNGAM causal discovery method.
Source code in causalflow/causal_discovery/baseline/VarLiNGAM.py
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
__init__(data, min_lag, max_lag, verbosity, alpha=0.05, resfolder=None, neglect_only_autodep=False, clean_cls=True)
Class constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Data
|
data to analyse. |
required |
min_lag |
int
|
minimum time lag. |
required |
max_lag |
int
|
maximum time lag. |
required |
verbosity |
CPLevel
|
verbosity level. |
required |
alpha |
float
|
PCMCI significance level. Defaults to 0.05. |
0.05
|
resfolder |
string
|
result folder to create. Defaults to None. |
None
|
neglect_only_autodep |
bool
|
Bit for neglecting variables with only autodependency. Defaults to False. |
False
|
clean_cls |
bool
|
Clean console bit. Default to True. |
True
|
Source code in causalflow/causal_discovery/baseline/VarLiNGAM.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
run()
Run causal discovery algorithm.
Returns:
Type | Description |
---|---|
DAG
|
estimated causal model. |
Source code in causalflow/causal_discovery/baseline/VarLiNGAM.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|