Skip to main content

RealLift

RealLift Logo

DOI

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:

  1. Data Quality (clean) — Missing value imputation, zero-rate filtering, and geo-level quality scoring.
  2. Auditable Planning (design) — Algorithmically selects optimal treatment/control clusters and projects statistical power (MDE) before any spend.
  3. 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.
  4. 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.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for reallift 0.8.0
File Size Uploaded Provenance Actions
reallift-0.8.0.tar.gz 1.4 MB With provenance Details for reallift-0.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for reallift 0.8.0
File Interpreter ABI Platform Actions
reallift-0.8.0-py3-none-any.whl Python 3 none any Details for reallift-0.8.0-py3-none-any.whl

Total release size: 1.6 MB

Release files / reallift-0.8.0.tar.gz

Download URL reallift-0.8.0.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
97e5179d282b5fdc62ed74a68799df09685e44e0966a71d7b1516477a817341a
BLAKE2b-256 checksum
How to use checksums
5a2547b82f03453f26a7b4258473cbebdbbb8957470b1a7bec405d30fd90e46a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 29, 2026.

Transparency log

Release files / reallift-0.8.0-py3-none-any.whl

Download URL reallift-0.8.0-py3-none-any.whl
Size 214.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe71a3281a4d78e53d012f4b7b1dd463a696c012c71e05c1baa57ff75465148a
BLAKE2b-256 checksum
How to use checksums
ebabf5c63625dbb2fb24aec2ef38735a1f6feffd9c9a7830a4c2bd4fb6703372
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 29, 2026.

Transparency log

Security for reallift 0.8.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.

Select from 2 files

Attestation for reallift-0.8.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 Jul 29, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page