Skip to main content

A causal feature selection (Causal DRIFT: Causal Dimensionality Reduction via Inference of Feature Treatments) library using residual-based ATE estimation.

Project description

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:

  1. Predict the outcome using confounders → compute residual (Ro)

  2. Predict the feature (treatment) using confounders → residual (Rt)

  3. Estimate ATE via linear regression: Ro ~ Rt

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

causalsoap-0.1.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

causalsoap-0.1.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file causalsoap-0.1.1.tar.gz.

File metadata

  • Download URL: causalsoap-0.1.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for causalsoap-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3b885ba168291be023b4c656d2e32383beb40b0aa0a9ab1f322cacf9ac3b68b6
MD5 c50cca5a9fc7d106807b18ddfdc061d2
BLAKE2b-256 daf063701f7d4094b687d2d9dc87f9796d16a267bbeebd0465c2843aacae780b

See more details on using hashes here.

File details

Details for the file causalsoap-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: causalsoap-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for causalsoap-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 890bd704bf45d904bcd72bedaa84c4b1fc044da396199a1c31565e61390416f4
MD5 b8e6e0f6d30c85cdac29853ef7b38572
BLAKE2b-256 c9e5a7126aa31d675760afe9a28f113425f40e5182038a53c99b082da46d13af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page