|
| 1 | +.. _BOSS: |
| 2 | + |
| 3 | +BOSS |
| 4 | +============================================== |
| 5 | + |
| 6 | +Algorithm Introduction |
| 7 | +-------------------------------------- |
| 8 | + |
| 9 | +Best order score search (BOSS) algorithm [1]_. |
| 10 | + |
| 11 | + |
| 12 | +Usage |
| 13 | +---------------------------- |
| 14 | +.. code-block:: python |
| 15 | +
|
| 16 | + from causallearn.search.PermutationBased.BOSS import boss |
| 17 | +
|
| 18 | + # default parameters |
| 19 | + G = boss(X) |
| 20 | +
|
| 21 | + # or customized parameters |
| 22 | + G = boss(X, score_func, parameters) |
| 23 | +
|
| 24 | + # Visualization using pydot |
| 25 | + from causallearn.utils.GraphUtils import GraphUtils |
| 26 | + import matplotlib.image as mpimg |
| 27 | + import matplotlib.pyplot as plt |
| 28 | + import io |
| 29 | +
|
| 30 | + pyd = GraphUtils.to_pydot(G) |
| 31 | + tmp_png = pyd.create_png(f="png") |
| 32 | + fp = io.BytesIO(tmp_png) |
| 33 | + img = mpimg.imread(fp, format='png') |
| 34 | + plt.axis('off') |
| 35 | + plt.imshow(img) |
| 36 | + plt.show() |
| 37 | +
|
| 38 | +Visualization using pydot is recommended (`usage example <https://github.com/cmu-phil/causal-learn/blob/main/tests/TestBOSS.py>`_). If specific label names are needed, please refer to this `usage example <https://github.com/cmu-phil/causal-learn/blob/e4e73f8b58510a3cd5a9125ba50c0ac62a425ef3/tests/TestGraphVisualization.py#L106>`_ (e.g., GraphUtils.to_pydot(G, labels=["A", "B", "C"]). |
| 39 | + |
| 40 | +Parameters |
| 41 | +------------------- |
| 42 | +**X**: numpy.ndarray, shape (n_samples, n_features). Data, where n_samples is the number of samples |
| 43 | +and n_features is the number of features. |
| 44 | + |
| 45 | +**score_func**: The score function you would like to use, including (see :ref:`score_functions`.). Default: 'local_score_BIC'. |
| 46 | + - ":ref:`local_score_BIC <BIC score>`": BIC score [3]_. |
| 47 | + - ":ref:`local_score_BDeu <BDeu score>`": BDeu score [4]_. |
| 48 | + - ":ref:`local_score_CV_general <Generalized score with cross validation>`": Generalized score with cross validation for data with single-dimensional variables [2]_. |
| 49 | + - ":ref:`local_score_marginal_general <Generalized score with marginal likelihood>`": Generalized score with marginal likelihood for data with single-dimensional variables [2]_. |
| 50 | + - ":ref:`local_score_CV_multi <Generalized score with cross validation>`": Generalized score with cross validation for data with multi-dimensional variables [2]_. |
| 51 | + - ":ref:`local_score_marginal_multi <Generalized score with marginal likelihood>`": Generalized score with marginal likelihood for data with multi-dimensional variables [2]_. |
| 52 | + |
| 53 | +**parameters**: Needed when using CV likelihood. Default: None. |
| 54 | + - parameters['kfold']: k-fold cross validation. |
| 55 | + - parameters['lambda']: regularization parameter. |
| 56 | + - parameters['dlabel']: for variables with multi-dimensions, indicate which dimensions belong to the i-th variable. |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +Returns |
| 61 | +------------------- |
| 62 | +- **G**: learned general graph, where G.graph[j,i]=1 and G.graph[i,j]=-1 indicate i --> j; G.graph[i,j] = G.graph[j,i] = -1 indicates i --- j. |
| 63 | + |
| 64 | + |
| 65 | +.. [1] Andrews, B., Ramsey, J., Sanchez Romero, R., Camchong, J., & Kummerfeld, E. (2023). Fast scalable and accurate discovery of dags using the best order score search and grow shrink trees. Advances in Neural Information Processing Systems, 36, 63945-63956. |
| 66 | +.. [2] Huang, B., Zhang, K., Lin, Y., Schölkopf, B., & Glymour, C. (2018, July). Generalized score functions for causal discovery. In Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining (pp. 1551-1560). |
| 67 | +.. [3] Schwarz, G. (1978). Estimating the dimension of a model. The annals of statistics, 461-464. |
| 68 | +.. [4] Buntine, W. (1991). Theory refinement on Bayesian networks. In Uncertainty proceedings 1991 (pp. 52-60). Morgan Kaufmann. |
0 commit comments