Causal Inference Library for Lift Measurement
Project description
RealLift
Causal Inference Framework for Geo Experiments & Marketing Science
RealLift is an advanced Python library engineered to measure the true incremental impact (Lift) of marketing interventions through rigorous Causal Inference, Synthetic Control methodologies, and Robust Significance Testing.
Framework Pillars
RealLift is built upon three layers of defense against noise and volatility:
- Auditable Planning (Design of Experiments): Algorithmically identifies the optimal geographic clusters and projects statistical power (MDE) prior to any campaign investment.
- Causal Inference (Synthetic Control): Formulates robust counterfactuals via Convex Optimization with Intercept, ensuring behavioral alignment even across differing baseline levels.
- Confidence Validation (Placebo & Significance): Defends analytical conclusions through permutation tests based on the MSPE Ratio and non-parametric Bootstrap confidence intervals.
Installation
pip install reallift
Quick Start Guide
This end-to-end example demonstrates how to simulate geographic data, plan the optimal experiment design, inject a simulated marketing effect, and precisely measure the impact.
1. Generate Historical Data
Simulate daily performance for 27 candidate geos over a 90-day baseline.
from reallift import generate_geo_data
geo_data = generate_geo_data(
start_date="2025-01-01",
end_date="2025-03-31",
n_geos=27,
pre_only=True,
trend_slope=0.01,
seasonality_amplitude=3,
seasonality_period=7,
noise_std=[1, 1.5],
base_value=[50, 100],
random_seed=42,
save_csv=True,
pre_file_name="demo_geodata_pre_test.csv"
)
2. Design the Experiment (Pre-Test Phase)
Use the DoE pipeline to rigorously select the best treatment and control geometries based on historical correlations.
from reallift import design_of_experiments
doe = design_of_experiments(
filepath="demo_geodata_pre_test.csv",
date_col="date",
start_date="2025-01-01",
end_date="2025-03-31",
pct_treatment=None,
fixed_treatment=None,
experiment_days=[21, 28, 30, 35, 60]
)
3. Inject Simulated Marketing Campaign
Simulate a 21-day campaign with an artificial lift applied strictly to the optimal treatment geos assigned in the DoE.
from reallift import generate_simulated_intervention
geo_data_intervention = generate_simulated_intervention(
filepath="demo_geodata_pre_test.csv",
days=21,
treatment_geos=doe['scenarios'][1]['treatment_pool'],
lift=[0.05, 0.10],
trend_slope=0.01,
seasonality_amplitude=3,
seasonality_period=7,
noise_std=[1, 1.5],
random_seed=42,
save_csv=True,
as_integer=True,
file_name="demo_geodata_post_test.csv"
)
4. Evaluate Incremental Impact (Post-Test Phase)
Measure the precise financial and percentual lift utilizing the Causal Inference engine against the final dataset.
from reallift import run_geo_experiment
results = run_geo_experiment(
filepath="demo_geodata_post_test.csv",
date_col="date",
treatment_start_date="2025-04-01",
treatment_end_date="2025-04-22",
doe=doe,
scenario=1,
plot=False
)
Technical Differentiators
- SER Engine (Synthetic Error Ratio): Proactive volatility filtering during the design phase to eliminate "Zombie Controls."
- Convex Intercept: Intelligent baseline shift absorption that preserves the interpretability of synthetic weights ($\sum w = 1$).
- MSPE Ratio Strategy: A placebo methodology resilient to the natural variance of high-frequency volatile markets.
- Operational Freedom: Aggressive donor curatorship via ElasticNet that often frees up to 50% of geographic regions for other commercial operations.
Systems & Dependencies
- Mathematics:
cvxpy,scipy,numpy - Data Engineering:
pandas,scikit-learn - Visualization:
matplotlib
Developed by Roberto Junior.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file reallift-0.3.0.tar.gz.
File metadata
- Download URL: reallift-0.3.0.tar.gz
- Upload date:
- Size: 2.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ca67e28492c757bbe360cc0b1d03481b5559066916d0ab76889e98befb20d03
|
|
| MD5 |
71bef710d0d232eae4f48ccf294e239a
|
|
| BLAKE2b-256 |
682f39c5ee28c9fd5255daad83c71e4cc157bc173452622b7fc8146ad88afd40
|
Provenance
The following attestation bundles were made for reallift-0.3.0.tar.gz:
Publisher:
publish.yml on RobertoJuniorWXYZ/RealLift
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
reallift-0.3.0.tar.gz -
Subject digest:
0ca67e28492c757bbe360cc0b1d03481b5559066916d0ab76889e98befb20d03 - Sigstore transparency entry: 1250004715
- Sigstore integration time:
-
Permalink:
RobertoJuniorWXYZ/RealLift@6365bd110f5e6e5af99cc58ff99e1658729150b9 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/RobertoJuniorWXYZ
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6365bd110f5e6e5af99cc58ff99e1658729150b9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file reallift-0.3.0-py3-none-any.whl.
File metadata
- Download URL: reallift-0.3.0-py3-none-any.whl
- Upload date:
- Size: 43.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f613649cd3c886211210f58a1ee2433d651e38e78da3f93afdc37780c3aa83e
|
|
| MD5 |
108fbd4df3ced99d930f50a2f0559d0d
|
|
| BLAKE2b-256 |
fb34a4da04f3b379cd66e36ba0bd041c46b5874522891c09b7b8e408026161de
|
Provenance
The following attestation bundles were made for reallift-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on RobertoJuniorWXYZ/RealLift
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
reallift-0.3.0-py3-none-any.whl -
Subject digest:
4f613649cd3c886211210f58a1ee2433d651e38e78da3f93afdc37780c3aa83e - Sigstore transparency entry: 1250004796
- Sigstore integration time:
-
Permalink:
RobertoJuniorWXYZ/RealLift@6365bd110f5e6e5af99cc58ff99e1658729150b9 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/RobertoJuniorWXYZ
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6365bd110f5e6e5af99cc58ff99e1658729150b9 -
Trigger Event:
push
-
Statement type: