Skip to content

Commit 204b36c

Browse files
committed
Update doc
1 parent 3d24d9c commit 204b36c

File tree

4 files changed

+58
-32
lines changed

4 files changed

+58
-32
lines changed

docs/source/search_methods_index/Constrained-based causal discovery methods/CDNOD.rst

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ Usage
1414
.. code-block:: python
1515
1616
from causallearn.search.ConstraintBased.CDNOD import cdnod
17-
G = cdnod(data, c_indx, alpha, indep_test, stable, uc_rule, uc_priority, mvpc, correction_name)
18-
G.to_nx_graph()
19-
G.draw_nx_graph(skel=False)
17+
G = cdnod(data, c_indx, alpha, indep_test, stable, uc_rule, uc_priority, mvcdnod,
18+
correction_name, background_knowledge, verbose, show_progress)
19+
20+
# visualization using pydot
21+
# note that the last node is the c_indx
22+
cg.draw_pydot_graph()
2023
2124
Parameters
2225
-------------------
@@ -25,23 +28,23 @@ and n_features is the number of features.
2528

2629
**c_indx**: time index or domain index that captures the unobserved changing factors.
2730

28-
**alpha**: desired significance level (float) in (0, 1).
31+
**alpha**: desired significance level (float) in (0, 1). Default: 0.05.
2932

30-
**indep_test**: Independence test method function.
33+
**indep_test**: Independence test method function. Default: 'fisherz'.
3134
- ":ref:`fisherz <Fisher-z test>`": Fisher's Z conditional independence test.
3235
- ":ref:`chisq <Chi-Square test>`": Chi-squared conditional independence test.
3336
- ":ref:`gsq <G-Square test>`": G-squared conditional independence test.
3437
- ":ref:`kci <Kernel-based conditional independence (KCI) test and independence test>`": kernel-based conditional independence test. (As a kernel method, its complexity is cubic in the sample size, so it might be slow if the same size is not small.)
3538
- ":ref:`mv_fisherz <Missing-value Fisher-z test>`": Missing-value Fisher's Z conditional independence test.
3639

37-
**stable**: run stabilized skeleton discovery if True (default = True).
40+
**stable**: run stabilized skeleton discovery if True. Default: True.
3841

39-
**uc_rule**: how unshielded colliders are oriented.
42+
**uc_rule**: how unshielded colliders are oriented. Default: 0.
4043
- 0: run uc_sepset.
4144
- 1: run maxP. Orient an unshielded triple X-Y-Z as a collider with an aditional CI test.
4245
- 2: run definiteMaxP. Orient only the definite colliders in the skeleton and keep track of all the definite non-colliders as well.
4346

44-
**uc_priority**: rule of resolving conflicts between unshielded colliders.
47+
**uc_priority**: rule of resolving conflicts between unshielded colliders. Default: 2.
4548
- -1: whatever is default in uc_rule.
4649
- 0: overwrite.
4750
- 1: orient bi-directed.
@@ -51,10 +54,17 @@ and n_features is the number of features.
5154

5255
**mvpc**: use missing-value PC or not. Default (and suggested for CDNOD): False.
5356

54-
**correction_name**. Missing value correction if using missing-value PC. Default: 'MV_Crtn_Fisher_Z'
57+
**correction_name**: Missing value correction if using missing-value PC. Default: 'MV_Crtn_Fisher_Z'
58+
59+
**background_knowledge**: class BackgroundKnowledge. Add prior edges according to assigned causal connections. Default: Nnoe.
60+
For detailed usage, please kindly refer to its `usage example <https://github.com/cmu-phil/causal-learn/blob/main/tests/TestBackgroundKnowledge.py>`_.
61+
62+
**verbose**: True iff verbose output should be printed. Default: False.
63+
64+
**show_progress**: True iff the algorithm progress should be show in console. Default: True.
5565

5666
Returns
5767
-------------------
58-
**cg** : a CausalGraph object. Nodes in the graph correspond to the column indices in the data.
68+
**cg** : a CausalGraph object, where cg.G.graph[j,i]=1 and cg.G.graph[i,j]=-1 indicates i --> j; cg.G.graph[i,j] = cg.G.graph[j,i] = -1 indicates i --- j; cg.G.graph[i,j] = cg.G.graph[j,i] = 1 indicates i <-> j.
5969

6070
.. [1] Huang, B., Zhang, K., Zhang, J., Ramsey, J. D., Sanchez-Romero, R., Glymour, C., & Schölkopf, B. (2020). Causal Discovery from Heterogeneous/Nonstationary Data. J. Mach. Learn. Res., 21(89), 1-53.

docs/source/search_methods_index/Constrained-based causal discovery methods/FCI.rst

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,45 @@ Usage
1414
.. code-block:: python
1515
1616
from causallearn.search.ConstraintBased.FCI import fci
17-
G = fci(data, indep_test, alpha, verbose, background_knowledge)
17+
G = fci(data, independence_test_method, alpha, depth, max_path_length,
18+
verbose, background_knowledge, cache_variables_map)
1819
1920
# visualization
20-
pgv_g = GraphUtils.to_pgv(G)
21-
pgv_g.draw('simple_test.png', prog='dot', format='png')
21+
from causallearn.utils.GraphUtils import GraphUtils
22+
pdy = GraphUtils.to_pydot(G)
23+
pdy.write_png('simple_test.png')
24+
2225
Parameters
2326
-------------------
24-
**data**: numpy.ndarray, shape (n_samples, n_features). Data, where n_samples is the number of samples
27+
**dataset**: numpy.ndarray, shape (n_samples, n_features). Data, where n_samples is the number of samples
2528
and n_features is the number of features.
2629

27-
**alpha**: Significance level of individual partial correlation tests.
28-
29-
**indep_test**: Independence test method function.
30+
**independence_test_method**: Independence test method function. Default: 'fisherz'.
3031
- ":ref:`fisherz <Fisher-z test>`": Fisher's Z conditional independence test.
3132
- ":ref:`chisq <Chi-Square test>`": Chi-squared conditional independence test.
3233
- ":ref:`gsq <G-Square test>`": G-squared conditional independence test.
3334
- ":ref:`kci <Kernel-based conditional independence (KCI) test and independence test>`": kernel-based conditional independence test. (As a kernel method, its complexity is cubic in the sample size, so it might be slow if the same size is not small.)
3435
- ":ref:`mv_fisherz <Missing-value Fisher-z test>`": Missing-value Fisher's Z conditional independence test.
3536

36-
**verbose**: 0 - no output, 1 - detailed output.
37+
**alpha**: Significance level of individual partial correlation tests. Default: 0.05.
38+
39+
**depth**: The depth for the fast adjacency search, or -1 if unlimited. Default: -1.
40+
41+
**max_path_length**: the maximum length of any discriminating path, or -1 if unlimited. Default: -1.
3742

38-
**background_knowledge**: class BackgroundKnowledge. Add prior edges according to assigned causal connections.
43+
**verbose**: True is verbose output should be printed or logged. Default: False.
44+
45+
**background_knowledge**: class BackgroundKnowledge. Add prior edges according to assigned causal connections. Default: None.
3946
For detailed usage, please kindly refer to its `usage example <https://github.com/cmu-phil/causal-learn/blob/main/tests/TestBackgroundKnowledge.py>`_.
4047

48+
**cache_variables_map**: This variable a map which contains the variables relate with cache. If it is not None, it should contain 'data_hash_key' 、'ci_test_hash_key' and 'cardinalities'. Default: None.
4149

4250

4351
Returns
4452
-------------------
45-
**G** : a GeneralGraph object. Nodes in the graph correspond to the column indices in the data. For visualization, please refer to the `running example <https://github.com/cmu-phil/causal-learn/tree/main/tests>`_.
53+
**graph**: a CausalGraph object, where graph.graph[j,i]=1 and graph.graph[i,j]=-1 indicates i --> j; graph.graph[i,j] = graph.graph[j,i] = -1 indicates i --- j; graph.graph[i,j] = graph.graph[j,i] = 1 indicates i <-> j; graph.graph[j,i]=1 and graph.graph[i,j]=2 indicates i o-> j.
54+
55+
**edges**: list. Contains graph's edges properties. If an edge.properties have the Property dd, then it means there is no latent confounder. Otherwise, there is possibly latent confounder. If an edge.properties have the Property nl, then it is definitely direct. Otherwise, it is possibly direct.
56+
4657

4758
.. [1] Spirtes, P., Meek, C., & Richardson, T. (1995, August). Causal inference in the presence of latent variables and selection bias. In Proceedings of the Eleventh conference on Uncertainty in artificial intelligence (pp. 499-506).

docs/source/search_methods_index/Constrained-based causal discovery methods/PC.rst

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Usage
1717
.. code-block:: python
1818
1919
from causallearn.search.ConstraintBased.PC import pc
20-
cg = pc(data, alpha, indep_test, stable, uc_rule, uc_priority, mvpc, correction_name, background_knowledge)
20+
cg = pc(data, alpha, indep_test, stable, uc_rule, uc_priority, mvpc, correction_name, background_knowledge, verbose, show_progress)
2121
2222
# visualization using pydot
2323
cg.draw_pydot_graph()
@@ -31,23 +31,23 @@ Parameters
3131
**data**: numpy.ndarray, shape (n_samples, n_features). Data, where n_samples is the number of samples
3232
and n_features is the number of features.
3333

34-
**alpha**: desired significance level (float) in (0, 1).
34+
**alpha**: desired significance level (float) in (0, 1). Default: 0.05.
3535

36-
**indep_test**: Independence test method function.
36+
**indep_test**: Independence test method function. Default: 'fisherz'.
3737
- ":ref:`fisherz <Fisher-z test>`": Fisher's Z conditional independence test.
3838
- ":ref:`chisq <Chi-Square test>`": Chi-squared conditional independence test.
3939
- ":ref:`gsq <G-Square test>`": G-squared conditional independence test.
4040
- ":ref:`kci <Kernel-based conditional independence (KCI) test and independence test>`": kernel-based conditional independence test. (As a kernel method, its complexity is cubic in the sample size, so it might be slow if the same size is not small.)
4141
- ":ref:`mv_fisherz <Missing-value Fisher-z test>`": Missing-value Fisher's Z conditional independence test.
4242

43-
**stable**: run stabilized skeleton discovery if True (default = True).
43+
**stable**: run stabilized skeleton discovery if True. Default: True.
4444

45-
**uc_rule**: how unshielded colliders are oriented.
45+
**uc_rule**: how unshielded colliders are oriented. Default: 0.
4646
- 0: run uc_sepset.
4747
- 1: run maxP. Orient an unshielded triple X-Y-Z as a collider with an aditional CI test.
4848
- 2: run definiteMaxP. Orient only the definite colliders in the skeleton and keep track of all the definite non-colliders as well.
4949

50-
**uc_priority**: rule of resolving conflicts between unshielded colliders.
50+
**uc_priority**: rule of resolving conflicts between unshielded colliders. Default: 2.
5151
- -1: whatever is default in uc_rule.
5252
- 0: overwrite.
5353
- 1: orient bi-directed.
@@ -59,12 +59,17 @@ and n_features is the number of features.
5959

6060
**correction_name**. Missing value correction if using missing-value PC. Default: 'MV_Crtn_Fisher_Z'
6161

62-
**background_knowledge**: class BackgroundKnowledge. Add prior edges according to assigned causal connections.
62+
**background_knowledge**: class BackgroundKnowledge. Add prior edges according to assigned causal connections. Default: Nnoe.
6363
For detailed usage, please kindly refer to its `usage example <https://github.com/cmu-phil/causal-learn/blob/main/tests/TestBackgroundKnowledge.py>`_.
6464

65+
**verbose**: True iff verbose output should be printed. Default: False.
66+
67+
**show_progress**: True iff the algorithm progress should be show in console. Default: True.
68+
69+
6570
Returns
6671
-------------------
67-
**cg** : a CausalGraph object. Nodes in the graph correspond to the column indices in the data.
72+
**cg** : a CausalGraph object, where cg.G.graph[j,i]=1 and cg.G.graph[i,j]=-1 indicates i --> j; cg.G.graph[i,j] = cg.G.graph[j,i] = -1 indicates i --- j; cg.G.graph[i,j] = cg.G.graph[j,i] = 1 indicates i <-> j.
6873

6974
.. [1] Spirtes, P., Glymour, C. N., Scheines, R., & Heckerman, D. (2000). Causation, prediction, and search. MIT press.
7075
.. [2] Tu, R., Zhang, C., Ackermann, P., Mohan, K., Kjellström, H., & Zhang, K. (2019, April). Causal discovery in the presence of missing data. In The 22nd International Conference on Artificial Intelligence and Statistics (pp. 1762-1770). PMLR.

docs/source/search_methods_index/Score-based causal discovery methods/GES.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ Parameters
2121
**X**: numpy.ndarray, shape (n_samples, n_features). Data, where n_samples is the number of samples
2222
and n_features is the number of features.
2323

24-
**score_func**: The score function you would like to use, including (see :ref:`score_functions`.).
24+
**score_func**: The score function you would like to use, including (see :ref:`score_functions`.). Default: 'local_score_BIC'.
2525
- ":ref:`local_score_BIC <BIC score>`": BIC score [3]_.
2626
- ":ref:`local_score_BDeu <BDeu score>`": BDeu score [4]_.
2727
- ":ref:`local_score_CV_general <Generalized score with cross validation>`": Generalized score with cross validation for data with single-dimensional variates [2]_.
2828
- ":ref:`local_score_marginal_general <Generalized score with marginal likelihood>`": Generalized score with marginal likelihood for data with single-dimensional variates [2]_.
2929
- ":ref:`local_score_CV_multi <Generalized score with cross validation>`": Generalized score with cross validation for data with multi-dimensional variables [2]_.
3030
- ":ref:`local_score_marginal_multi <Generalized score with marginal likelihood>`": Generalized score with marginal likelihood for data with multi-dimensional variates [2]_.
3131

32-
**maxP**: Allowed maximum number of parents when searching the graph.
32+
**maxP**: Allowed maximum number of parents when searching the graph. Default: None.
3333

34-
**parameters**: when using CV likelihood,
34+
**parameters**: Needed when using CV likelihood. Default: None.
3535
- parameters['kfold']: k-fold cross validation.
3636
- parameters['lambda']: regularization parameter.
3737
- parameters['dlabel']: for variables with multi-dimensions, indicate which dimensions belong to the i-th variable.
@@ -40,7 +40,7 @@ and n_features is the number of features.
4040

4141
Returns
4242
-------------------
43-
- **Record['G']**: learned causal graph.
43+
- **Record['G']**: learned causal graph, where Record['G'].graph[j,i]=1 and Record['G'].graph[i,j]=-1 indicates i --> j; Record['G'].graph[i,j] = Record['G'].graph[j,i] = -1 indicates i --- j.
4444

4545
- **Record['update1']**: each update (Insert operator) in the forward step.
4646

0 commit comments

Comments
 (0)