FCI
算法介绍
使用快速因果推断(FCI [1])进行因果发现。
使用方法
from causallearn.search.ConstraintBased.FCI import fci
# default parameters
g, edges = fci(data)
# or customized parameters
g, edges = fci(data, independence_test_method, alpha, depth, max_path_length,
verbose, background_knowledge, cache_variables_map)
# visualization
from causallearn.utils.GraphUtils import GraphUtils
pdy = GraphUtils.to_pydot(g)
pdy.write_png('simple_test.png')
推荐使用 pydot 进行可视化。如果需要特定的标签名称,请参考此使用示例。
参数
dataset: numpy.ndarray,形状为 (n_samples, n_features)。数据,其中 n_samples 是样本数,n_features 是特征数。
- independence_test_method: 独立性检验方法函数。默认值: ‘fisherz’。
“fisherz”: Fisher's Z 条件独立性检验。
“chisq”: 卡方条件独立性检验。
“gsq”: G平方条件独立性检验。
“kci”: 基于核的条件独立性检验。(作为一种核方法,其复杂度与样本大小的立方成正比,因此如果样本大小不是很大,它可能会很慢。)
“mv_fisherz”: 缺失值 Fisher's Z 条件独立性检验。
(对于更有效的非参数检验,您可以尝试 FastKCI 和 RCIT。这两种实现都还是初步的,可能存在一些问题。)
alpha: 单个偏相关检验的显著性水平。默认值: 0.05。
depth: 用于快速邻接搜索的深度,如果无限制则为 -1。默认值: -1。
max_path_length: 任何判别路径的最大长度,如果无限制则为 -1。默认值: -1。
verbose: 如果应打印或记录详细输出,则为 True。默认值: False。
background_knowledge: BackgroundKnowledge 类。根据指定的因果连接添加先验边。默认值: None。有关详细用法,请参考其使用示例。
cache_variables_map: 此变量是一个包含与缓存相关的变量的映射。如果它不是 None,则应包含 ‘data_hash_key’、‘ci_test_hash_key’ 和 ‘cardinalities’。默认值: None。
show_progress: 当算法进度应在控制台中显示时为 True。默认值: True。
返回值
g: 一个 GeneralGraph 对象,其中 g.graph 是一个 PAG,其末端节点的说明如下所示(表示 G = g.graph)

- edges: list。包含图的边的属性。
如果 edge.properties 具有属性 ‘nl’,则没有潜在混杂因子。否则,可能存在潜在混杂因子。
如果 edge.properties 具有属性 ‘dd’,则它肯定是直接的。否则,它可能是直接的。
如果 edge.properties 具有属性 ‘pl’,则可能存在潜在混杂因子。否则,没有潜在混杂因子。
如果 edge.properties 具有属性 ‘pd’,则它可能是直接的。否则,它肯定是直接的。