Skip to main content

A validation framework for causal models.

Project description

Causal Validation

This package provides functionality to define your own causal data generation process and then simulate data from the process. Within the package, there is functionality to include complex components to your process, such as periodic and temporal trends, and all of these operations are fully composable with one another.

A short example is given below

from causal_validation import Config, simulate
from causal_validation.effects import StaticEffect
from causal_validation.plotters import plot
from causal_validation.transforms import Trend, Periodic
from causal_validation.transforms.parameter import UnitVaryingParameter
from scipy.stats import norm

cfg = Config(
    n_control_units=10,
    n_pre_intervention_timepoints=60,
    n_post_intervention_timepoints=30,
)

# Simulate the base observation
base_data = simulate(cfg)

# Apply a linear trend with unit-varying intercept
intercept = UnitVaryingParameter(sampling_dist = norm(0, 1))
trend_component = Trend(degree=1, coefficient=0.1, intercept=intercept)
trended_data = trend_component(base_data)

# Simulate a 5% lift in the treated unit's post-intervention data
effect = StaticEffect(0.05)
inflated_data = effect(trended_data)

# Plot your data
plot(inflated_data)

Examples

To supplement the above example, we have two more detailed notebooks which exhaustively present and explain the functionalty in this package, along with how the generated data may be integrated with AZCausal.

  1. Basic notebook: We here show the full range of available functions for data generation
  2. AZCausal notebook: We here show how the generated data may be used within an AZCausal model.

Installation

In this section we guide the user through the installation of this package. We distinguish here between users of the package who seek to define their own data generating processes, and developers who wish to extend the existing functionality of the package.

Prerequisites

  • Python 3.10 or higher
  • Hatch (optional, but recommended)

For Users

  1. It's strongly recommended to use a virtual environment. Create and activate one using your preferred method before proceeding with the installation.
  2. Clone the package git clone git@github.com:amazon-science/causal-validation.git
  3. Enter the package's root directory cd SyntheticCausalDataGen
  4. Install the package pip install -e .

For Developers

  1. Follow steps 1-3 from For Users
  2. Create a hatch environment hatch env create
  3. Open a hatch shell hatch shell
  4. Validate your installation by running hatch run tests:test

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

causal_validation-0.0.2.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

causal_validation-0.0.2-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file causal_validation-0.0.2.tar.gz.

File metadata

  • Download URL: causal_validation-0.0.2.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for causal_validation-0.0.2.tar.gz
Algorithm Hash digest
SHA256 7a33c769f74ef312893551e16698565b509e8d2c16560fd08f153e4443d88843
MD5 9aad50f7badc16ecfec8eed36ad9b6b5
BLAKE2b-256 4fd7eb4aada3de7f740bc482ade3a902b36ec5f94f575560eef4a07a3e22089c

See more details on using hashes here.

File details

Details for the file causal_validation-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for causal_validation-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f9360e1cadbf242f7634690473e20454ce3767b0a40f9811d848594db28e3972
MD5 401229bd04ac25d4049efa72372aaed4
BLAKE2b-256 219273f83f5687bdf8232a448bfe7748b17d8526db667e054bd72a5fb07d876a

See more details on using hashes here.

Supported by

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