causalsoap
Causal Feature Selection and Dimensionality Reduction using Residual-Based ATE Estimation
Author: Kazi Sakib Hasan
💡 What is causalsoap?
causalsoap is a Python library for causal inference-driven feature selection and dimensionality reduction technique.
It ranks features based on their Average Treatment Effect (ATE) on an outcome variable by applying the Frisch–Waugh–Lovell (FWL) theorem using residualization and double machine learning.
This method is particularly useful when:
- You want interpretable ranking of features by causal effect
- The dataset has confounders
- Traditional correlation-based selection is misleading
Link to preprint will be available soon.
📦 Installation
pip install causalsoap
🚀 Quickstart
import pandas as pd
import numpy as np
from causalsoap import CausalDRIFT
# Simulated data
df = pd.DataFrame({
'X1': np.random.randn(100),
'X2': np.random.rand(100),
'X3': np.random.randn(100),
'X4': np.random.choice([0, 1, 2], size=100), # categorical numeric
'Y': np.random.randn(100)
})
# Run model
X = df.drop(columns='Y')
y = df['Y']
model = CausalDRIFT()
model.fit(X, y, outcome_type='continuous', categorical_features=['X4'])
print(model.get_feature_ate())
⚙️ Parameters
fit(X, y, outcome_type, categorical_features=None)
X : Feature matrix (all numeric) pd.DataFrame
y : Target variable pd.Series
outcome_type : Continuous or categorical str
categorical_features: List of column names in X that are categorical but encoded numerically list[str]
## 📈 How it Works
For each feature:
-
Predict the outcome using confounders → compute residual (
Ro) -
Predict the feature (treatment) using confounders → residual (
Rt) -
Estimate ATE via linear regression:
Ro ~ Rt
Release files for causalsoap 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| causalsoap-0.1.1.tar.gz | 4.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| causalsoap-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.5 kB
Release files / causalsoap-0.1.1.tar.gz
| Download URL | causalsoap-0.1.1.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b885ba168291be023b4c656d2e32383beb40b0aa0a9ab1f322cacf9ac3b68b6
|
|
BLAKE2b-256 checksum How to use checksums |
daf063701f7d4094b687d2d9dc87f9796d16a267bbeebd0465c2843aacae780b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Release files / causalsoap-0.1.1-py3-none-any.whl
| Download URL | causalsoap-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
890bd704bf45d904bcd72bedaa84c4b1fc044da396199a1c31565e61390416f4
|
|
BLAKE2b-256 checksum How to use checksums |
c9e5a7126aa31d675760afe9a28f113425f40e5182038a53c99b082da46d13af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|