Skip to content
Scenario1 min read

Python CUPED Library

How to use Causalis as a Python CUPED library for randomized experiments with pre-treatment outcome data and variance reduction diagnostics.

Python CUPED Library

Use Causalis for CUPED in Python when you have a randomized experiment and a pre-treatment outcome or strong pre-period covariate. Causalis provides a scenario workflow, CausalData contract, CUPEDModel, and diagnostics around the estimate.

CUPED is not a replacement for randomization. It is a variance-reduction method for experiments where the pre-treatment signal was measured before assignment.

Minimal CUPED Example

Data Shape

The dataframe should include:

  • a randomized treatment column, usually binary;
  • an outcome column measured after assignment;
  • one or more pre-treatment covariates, commonly y_pre;
  • optional user or unit identifiers.

Diagnostics

Use SRM checks to catch assignment problems, balance checks to inspect pre-treatment covariates, and CUPED plots or regression checks to understand variance reduction.

When Not to Use CUPED

  • The covariate was measured after treatment assignment.
  • Treatment was not randomized.
  • The pre-period signal is unrelated to the post-period outcome.
  • There is assignment instrumentation risk or sample-ratio mismatch that has not been resolved.

Common Mistakes

  • Calling a post-treatment variable a CUPED covariate.
  • Treating CUPED as an observational confounding adjustment method.
  • Reporting only the point estimate and not the variance reduction or diagnostics.
  • Forgetting to explain that the causal identification still comes from random assignment.