dowhy.do_samplers 包#
子模块#
dowhy.do_samplers.kernel_density_sampler 模块#
- class dowhy.do_samplers.kernel_density_sampler.KernelDensitySampler(*args, **kwargs)[source]#
基础类:
DoSampler使用数据和相关变量的名称初始化一个do采样器。
采样实现了Pearl(2000)中的do()操作。这个操作是在因果贝叶斯网络上定义的,其显式实现是MCMC采样方法的基础。
我们将三步过程背后的思想抽象化,以允许其他方法。disrupt_causes方法是使治疗分配可忽略的手段。在Pearl框架中,这是我们切断指向因果状态的边的地方。对于其他方法,这通常是通过使用一些假设条件可忽略性的方法(例如加权,或使用Robins G公式进行显式调节)来实现的。
接下来,make_treatment_effective 方法反映了我们施加的干预是“有效的”这一假设。最简单的情况下,我们将因果状态固定为某个特定值。如果因果状态没有指定值,则跳过此步骤,使用原始值代替。
最后,我们从结果分布中进行采样。这可以是从point_sample方法中采样,如果推理方法不支持批量采样,或者从sample方法中采样,如果支持。为了方便,point_sample方法使用multiprocessing进行并行化,使用num_cores kwargs来设置用于并行化的核心数量。
虽然不同的方法会有自己的类属性,但_df方法应该是所有方法共有的。这是一个临时数据集,最初是原始数据的副本,并被修改以反映do操作的步骤。阅读现有方法(加权可能是最简单的)以了解如何自己实现这一点。
- Parameters:
data – 包含数据的 pandas.DataFrame
identified_estimand – dowhy.causal_identifier.IdentifiedEstimand: 使用后门方法的估计量
用于效果识别。 :param treatments: list or str: 处理变量的名称 :param outcomes: list or 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)[来源]#
基础类:
DoSamplerg, 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)[来源]#
基础类:
DoSamplerg, 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]#
基础类:
DoSamplerg, df, data_types