dowhy.do_samplers 包#
子模块#
dowhy.do_samplers.kernel_density_sampler 模块#
- class dowhy.do_samplers.kernel_density_sampler.KernelDensitySampler(*args, **kwargs)[source]#
基类:
DoSampler
使用数据和相关变量名初始化 do 采样器。
Do 采样实现了 Pearl (2000) 的 do() 操作。此操作定义在因果贝叶斯网络上,其显式实现是 MCMC 采样方法的基础。
我们将三步过程背后的思想抽象化,以允许其他方法。 disrupt_causes 方法是使处理分配可忽略的手段。在 Pearlian 框架中,这是我们切断指向因果状态的边的地方。对于其他方法,这通常是通过使用假设条件可忽略性的一些方法来实现的(例如,加权,或使用 Robins G-formula 进行显式条件化)。
接下来, make_treatment_effective 方法反映了我们施加的干预是“有效”的假设。最简单地说,我们将因果状态固定到某个特定值。如果未为因果状态指定值,则跳过此步骤,而是使用原始值。
最后,我们从结果分布中采样。这可以是来自 point_sample 方法(如果推理方法不支持批量采样),或者来自 sample 方法(如果支持批量采样)。为了方便起见, point_sample 方法使用 multiprocessing 进行并行化,并使用 num_cores kwargs 设置用于并行化的核心数量。
虽然不同的方法将有自己的类属性,但 _df 方法应该对所有方法都是通用的。这是临时数据集,它以原始数据的副本开始,并进行修改以反映 do 操作的步骤。阅读现有方法(加权可能是最简单的)以了解其工作原理,以便自己实现一个方法。
- 参数:
data – 包含数据的 pandas.DataFrame
identified_estimand – dowhy.causal_identifier.IdentifiedEstimand: 使用后门方法得到的估计量
用于效果识别。 :param treatments: list 或 str: 处理变量的名称 :param outcomes: list 或 str: 结果变量的名称 :param variable_types: dict: 包含变量名称和类型的字典。‘c’ 表示连续型,‘o’ 表示有序型,‘d’ 表示离散型,‘u’ 表示无序离散型。 :param keep_original_treatment: bool: 是否使用 make_treatment_effective,或保留原始处理分配。 :param params: (可选) 附加方法参数
dowhy.do_samplers.mcmc_sampler 模块#
- class dowhy.do_samplers.mcmc_sampler.McmcSampler(graph: DiGraph, action_nodes: List[str], outcome_nodes: List[str], observed_nodes: List[str], data, params=None, variable_types=None, num_cores=1, keep_original_treatment=False, estimand_type=EstimandType.NONPARAMETRIC_ATE)[source]#
基类:
DoSampler
g, df, data_types
dowhy.do_samplers.multivariate_weighting_sampler 模块#
- class dowhy.do_samplers.multivariate_weighting_sampler.MultivariateWeightingSampler(graph: DiGraph, action_nodes: List[str], outcome_nodes: List[str], observed_nodes: List[str], data, params=None, variable_types=None, num_cores=1, keep_original_treatment=False, estimand_type=EstimandType.NONPARAMETRIC_ATE)[source]#
基类:
DoSampler
g, df, data_types
dowhy.do_samplers.weighting_sampler 模块#
- class dowhy.do_samplers.weighting_sampler.WeightingSampler(graph: DiGraph, action_nodes: List[str], outcome_nodes: List[str], observed_nodes: List[str], data, params=None, variable_types=None, num_cores=1, keep_original_treatment=False, estimand_type=EstimandType.NONPARAMETRIC_ATE)[source]#
基类:
DoSampler
g, df, data_types