RealLift
Causal Inference Framework for Geo Experiments & Marketing Science
RealLift is a Python library for measuring the true incremental impact of marketing interventions through Synthetic Control, Convex Optimization, and robust significance testing — designed for markets where individual-level tracking is unavailable.
Framework Pillars
Four layers of defense against noise and spurious correlations:
- Data Quality (
clean) — Missing value imputation, zero-rate filtering, and geo-level quality scoring. - Auditable Planning (
design) — Algorithmically selects optimal treatment/control clusters and projects statistical power (MDE) before any spend. - Causal Inference (
run) — Builds counterfactuals via Penalized Synthetic Control (PSCM — convex optimization with L1+L2 penalties) with Intercept Adjustment, ensuring behavioral alignment across differing baseline levels. The canonical, default method (method="penalized_scm"); ElasticNet- and classic-SCM-based alternatives are also available. - Confidence Validation — Circular Moving Block Bootstrap (CMBB) drives the canonical significance test; OOS Ghost Lift detection (design-time) and Placebo/Permutation testing (post-hoc, opt-in) are available as additional diagnostics.
Installation
pip install reallift
Quick Start
The API is object-oriented. Instantiate a GeoExperiment via the RealLift namespace — it holds the data in memory across all pipeline steps.
1. Initialize
from reallift import RealLift
# Accepts a CSV path or a pandas DataFrame
rl = RealLift.GeoExperiment(
"geo_daily_sales.csv",
date_col="date",
start_date="2025-01-01", # optional: window the analysis period
end_date="2025-04-30",
)
2. Clean
df_clean = rl.clean(
imputation_method="constant", # "constant" or "interpolation"
max_zero_rate=0.0, # drop geos with any zero-revenue days
keep_top_quantiles=1, # keep only top revenue quantile
quantile_bins=40,
save_pdf=True,
pdf_name="DataQualityReport.pdf",
)
3. Design (Pre-Test Phase)
doe = rl.design(
pct_treatment=[0.05, 0.10, 0.15], # treatment pool sizes to evaluate
experiment_days=[21, 28, 35], # durations to evaluate
check_ghost_lift=True, # OOS backtest for spurious effects
save_pdf=True,
pdf_name="DoEReport.pdf",
)
# Visual diagnostics
doe.plot_cluster_fits(scenario=0) # pre-period synthetic control fit per cluster
doe.plot_consolidated_fit(scenario=0) # aggregated control group fit
doe.plot_power_analysis() # MDE curves vs. experiment duration
4. Run (Post-Test Phase)
Option A — Backtest on historical data (validate the design before the campaign):
results = rl.run(
perform_backtesting={"lift": 0.0, "days": 28}, # inject a known 0% lift on real history
doe=doe,
scenario=0,
)
Option B — Real campaign analysis (after the campaign ends, load data that includes the treatment period):
rl_post = RealLift.GeoExperiment("geo_daily_sales_with_campaign.csv", date_col="date")
rl_post.clean()
results = rl_post.run(
treatment_start_date="2025-04-01",
treatment_end_date="2025-04-28",
doe=doe,
scenario=0,
)
5. Visualize Results
results.plot_cluster_effects(post_only=False) # treatment vs. synthetic per cluster
results.plot_consolidated_effect(post_only=False) # aggregated causal impact
results.plot_cluster_lift_distributions(show_null=True) # per-cluster bootstrap CI + hypothesis test
results.plot_consolidated_lift_distributions(show_null=True) # aggregated bootstrap CI + hypothesis test
Hands-on example:
examples/GeoExperiment/GeoExperiment-Quickstart.ipynb— full pipeline with synthetic data, no setup required.
Key Algorithms
| Algorithm | Role |
|---|---|
| Penalized SCM (PSCM) | Canonical donor-weighting method (method="penalized_scm", default) — a single convex step with L1+L2 penalties and w ≥ 0 (weights normalized after solving). Alternatives ("elastic_net", "scm") are available but not the default |
| Convex Intercept | Absorbs baseline shift between treated and synthetic while preserving Σw = 1 |
| Synchronization Error Ratio (SER) | Pre-experiment geo ranking and volatility scoring |
| Circular Moving Block Bootstrap (CMBB) | Treats the pre-period as circular (wrap-around blocks), so every observation contributes equally — respects temporal autocorrelation (~7-day blocks) for conservative, edge-effect-free CIs. Drives the canonical significance test |
| OOS Ghost Lift Detection | Weekly-aligned backtest that flags spurious effects in the experiment design (design(check_ghost_lift=True), default) |
| Placebo / MSPE Ratio (optional diagnostic) | Permutation-based empirical p-values (Abadie et al., 2010). Computed but not shown/required by default — pass show_diagnostics=True to see it or require_placebo=True to gate significance on it |
Dependencies
- Optimization:
cvxpy,scipy,numpy - Data:
pandas,scikit-learn - Visualization:
matplotlib - Utilities:
tqdm
Developed by Roberto Junior.
Citation
If you use RealLift in your research or applied work, please cite:
@misc{junior2026reallift,
author = {Junior, Roberto},
title = {RealLift: Robust Design and Inference for Geo-Experimentation},
year = {2026},
doi = {10.5281/zenodo.20329451},
url = {https://doi.org/10.5281/zenodo.20329451},
note = {Preprint}
}
Metadata
Release files for reallift 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| reallift-0.9.0.tar.gz | 1.4 MB | With provenance | Details for reallift-0.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| reallift-0.9.0-py3-none-any.whl | Python 3 | none | any | Details for reallift-0.9.0-py3-none-any.whl |
Total release size: 1.6 MB
Release files / reallift-0.9.0.tar.gz
| Download URL | reallift-0.9.0.tar.gz |
|---|---|
| Size | 1.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
215b420da27ce93af47b6462982a5dea9e391c194c7d96b7512141344fb4939b
|
|
BLAKE2b-256 checksum How to use checksums |
a070985435c0d83dc9de1eb69f32072d24427bedbb11948fc5a8eba6ced0b6e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.
Transparency logRelease files / reallift-0.9.0-py3-none-any.whl
| Download URL | reallift-0.9.0-py3-none-any.whl |
|---|---|
| Size | 220.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bbf06d40634fe6586ea2f94c99c404a61ed9fee0a1185ff94cc802e9de6cb5d9
|
|
BLAKE2b-256 checksum How to use checksums |
99af7d7e522f3198167341a9f86e086bac4c18218784cef3ef7ab2e1ff3114fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.
Transparency logSecurity for reallift 0.9.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for reallift-0.9.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.