causalkit.eda.eda.CausalEDA.treatment_features#

CausalEDA.treatment_features()[source]#

Return SHAP values from the fitted propensity score model.

This method extracts SHAP values from the propensity score model that was trained during fit_propensity(). SHAP values show the directional contribution of each feature to treatment assignment prediction, where positive values increase treatment probability and negative values decrease it.

Returns:

For CatBoost models: DataFrame with columns ‘feature’ and ‘shap_mean’, where ‘shap_mean’ represents the mean SHAP value across all samples. Positive values indicate features that increase treatment probability, negative values indicate features that decrease treatment probability.

For sklearn models: DataFrame with columns ‘feature’ and ‘importance’ (absolute coefficient values, for backward compatibility).

Return type:

pd.DataFrame

Raises:

RuntimeError – If fit_propensity() has not been called yet, or if the fitted model does not support SHAP values extraction.

Examples

>>> eda = CausalEDA(data)
>>> ps = eda.fit_propensity()  # Must be called first
>>> shap_df = eda.treatment_features()
>>> print(shap_df.head())
   feature  shap_mean
0  age         0.45  # Positive: increases treatment prob
1  income     -0.32  # Negative: decreases treatment prob
2  education   0.12  # Positive: increases treatment prob