= CausalModel('sanity_3_lin') scm
Causal Graphical Models
Encoding causality into the CF explanation generation.
Distributions
https://github.com/amirhk/recourse/blob/master/distributions.py
BASEDISTRIBUTION
CLASS relax.data.scm.BaseDistribution (name)
Base class for all distributions.
MIXTUREOFGAUSSIANS
CLASS relax.data.scm.MixtureOfGaussians (probs, means, vars)
Mixture of Gaussians distribution.
NORMAL
CLASS relax.data.scm.Normal (mean, var)
Normal distribution.
Load SCM
Load scm structural equations.
SANITY_3_LIN
relax.data.scm.sanity_3_lin ()
Causal Model
CAUSALMODEL
CLASS relax.data.scm.CausalModel (scm_class)
Class with topological methods given a structural causal model.
Credit goes to the CARLA implementation.
assert scm.get_children('x1') == {'x2', 'x3'}
assert scm.get_parents('x3') == ['x1', 'x2']
assert scm.get_ancestors('x3') == ['x1', 'x2']
assert scm.get_descendants('x1') == ['x2', 'x3']
assert scm.get_non_descendants('x1') == set()
Generate synthethic Data
Adapted from Carla.
(Experimental) Data Module
= CausalModel('sanity_3_lin')
scm = _create_synthetic_data(scm, 1000)
df_endogenous, df_exogenous = TabularDataModuleConfigs(
d_config =".",
data_dir='sanity_3_lin',
data_name=scm._continuous,
continous_cols=scm._categorical,
discret_cols )
= TabularDataModule(d_config, data=df_endogenous) dm
setattr(dm, 'scm', scm)
setattr(dm, 'exogenous', df_exogenous)
assert isinstance(dm.scm, CausalModel)
assert isinstance(dm.exogenous, pd.DataFrame)