BOSS
Algorithm Introduction
Best order score search (BOSS) algorithm [1].
Usage
from causallearn.search.PermutationBased.BOSS import boss
# default parameters
G = boss(X)
# or customized parameters
G = boss(X, score_func, parameters)
# Visualization using pydot
from causallearn.utils.GraphUtils import GraphUtils
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
import io
pyd = GraphUtils.to_pydot(G)
tmp_png = pyd.create_png(f="png")
fp = io.BytesIO(tmp_png)
img = mpimg.imread(fp, format='png')
plt.axis('off')
plt.imshow(img)
plt.show()
Visualization using pydot is recommended (usage example). If specific label names are needed, please refer to this usage example (e.g., GraphUtils.to_pydot(G, labels=[“A”, “B”, “C”]).
Parameters
X: numpy.ndarray, shape (n_samples, n_features). Data, where n_samples is the number of samples and n_features is the number of features.
- score_func: The score function you would like to use, including (see score_functions.). Default: ‘local_score_BIC’.
“local_score_BIC”: BIC score [3].
“local_score_BDeu”: BDeu score [4].
“local_score_CV_general”: Generalized score with cross validation for data with single-dimensional variables [2].
“local_score_marginal_general”: Generalized score with marginal likelihood for data with single-dimensional variables [2].
“local_score_CV_multi”: Generalized score with cross validation for data with multi-dimensional variables [2].
“local_score_marginal_multi”: Generalized score with marginal likelihood for data with multi-dimensional variables [2].
- parameters: Needed when using CV likelihood. Default: None.
parameters[‘kfold’]: k-fold cross validation.
parameters[‘lambda’]: regularization parameter.
parameters[‘dlabel’]: for variables with multi-dimensions, indicate which dimensions belong to the i-th variable.
Returns
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.