dowhy.causal_refuters package¶
Submodules¶
dowhy.causal_refuters.add_unobserved_common_cause module¶
-
class
dowhy.causal_refuters.add_unobserved_common_cause.
AddUnobservedCommonCause
(*args, **kwargs)[source]¶ Bases:
dowhy.causal_refuter.CausalRefuter
Add an unobserved confounder for refutation.
Supports additional parameters that can be specified in the refute_estimate() method.
‘confounders_effect_on_treatment’: how the simulated confounder affects the value of treatment. This can be linear (for continuous treatment) or binary_flip (for binary treatment)
‘confounders_effect_on_outcome’: how the simulated confounder affects the value of outcome. This can be linear (for continuous outcome) or binary_flip (for binary outcome)
‘effect_strength_on_treatment’: parameter for the strength of the effect of simulated confounder on treatment. For linear effect, it is the regression coeffient. For binary_flip, it is the probability that simulated confounder’s effect flips the value of treatment from 0 to 1 (or vice-versa).
‘effect_strength_on_outcome’: parameter for the strength of the effect of simulated confounder on outcome. For linear effect, it is the regression coeffient. For binary_flip, it is the probability that simulated confounder’s effect flips the value of outcome from 0 to 1 (or vice-versa).
TODO: Needs scaled version of the parameters and an interpretation module (e.g., in comparison to biggest effect of known confounder)
-
include_confounders_effect
(new_data, kappa_t, kappa_y)[source]¶ This function deals with the change in the value of the data due to the effect of the unobserved confounder. In the case of a binary flip, we flip only if the random number is greater than the threshold set. In the case of a linear effect, we use the variable as the linear regression constant.
- Parameters
new_data – pandas.DataFrame: The data to be changed due to the effects of the unobserved confounder.
kappa_t – numpy.float64: The value of the threshold for binary_flip or the value of the regression coefficient for linear effect.
kappa_y – numpy.float64: The value of the threshold for binary_flip or the value of the regression coefficient for linear effect.
- Returns
pandas.DataFrame: The DataFrame that includes the effects of the unobserved confounder.
-
refute_estimate
()[source]¶ This function attempts to add an unobserved common cause to the outcome and the treatment. At present, we have implemented the behavior for one dimensional behaviors for continueous and binary variables. This function can either take single valued inputs or a range of inputs. The function then looks at the data type of the input and then decides on the course of action.
- Returns
CausalRefuter: An object that contains the estimated effect and a new effect and the name of the refutation used.
dowhy.causal_refuters.bootstrap_refuter module¶
-
class
dowhy.causal_refuters.bootstrap_refuter.
BootstrapRefuter
(*args, **kwargs)[source]¶ Bases:
dowhy.causal_refuter.CausalRefuter
Refute an estimate by running it on a random sample of the original data. It supports additional parameters that can be specified in the refute_estimate() method. - ‘num_simulations’: int, CausalRefuter.DEFAULT_NUM_SIMULATIONS by default The number of bootstrap simulations to be run - ‘sample_size’: int, Size of the original data by default The size of each bootstrap sample - ‘random_state’: int, RandomState, None by default The seed value to be added if we wish to repeat the same random behavior. For this purpose, we repeat the same seed in the psuedo-random generator.
dowhy.causal_refuters.data_subset_refuter module¶
-
class
dowhy.causal_refuters.data_subset_refuter.
DataSubsetRefuter
(*args, **kwargs)[source]¶ Bases:
dowhy.causal_refuter.CausalRefuter
Refute an estimate by rerunning it on a random subset of the original data.
Supports additional parameters that can be specified in the refute_estimate() method.
‘subset_fraction’: float, 0.8 by default
Fraction of the data to be used for re-estimation. - ‘num_simulations’: int, CausalRefuter.DEFAULT_NUM_SIMULATIONS by default The number of simulations to be run - random_state’: int, RandomState, None by default The seed value to be added if we wish to repeat the same random behavior. If we with to repeat the same behavior we push the same seed in the psuedo-random generator
dowhy.causal_refuters.placebo_treatment_refuter module¶
-
class
dowhy.causal_refuters.placebo_treatment_refuter.
PlaceboTreatmentRefuter
(*args, **kwargs)[source]¶ Bases:
dowhy.causal_refuter.CausalRefuter
Refute an estimate by replacing treatment with a randomly-generated placebo variable.
Supports additional parameters that can be specified in the refute_estimate() method.
‘placebo_type’: str, None by default
Default is to generate random values for the treatment. If placebo_type is “permute”, then the original treatment values are permuted by row. - ‘num_simulations’: int, CausalRefuter.DEFAULT_NUM_SIMULATIONS by default The number of simulations to be run - ‘random_state’: int, RandomState, None by default The seed value to be added if we wish to repeat the same random behavior. If we with to repeat the same behavior we push the same seed in the psuedo-random generator
dowhy.causal_refuters.random_common_cause module¶
-
class
dowhy.causal_refuters.random_common_cause.
RandomCommonCause
(*args, **kwargs)[source]¶ Bases:
dowhy.causal_refuter.CausalRefuter
Refute an estimate by introducing a randomly generated confounder (that may have been unobserved).