causal-validation


Namecausal-validation JSON
Version 0.0.9 PyPI version JSON
download
home_pageNone
SummaryA validation framework for causal models.
upload_time2024-10-23 05:04:40
maintainerNone
docs_urlNone
authorNone
requires_python<4.0,>=3.10
licenseNone
keywords causal model machine learning synthetic data
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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
```python
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)
```

![](https://raw.githubusercontent.com/amazon-science/causal-validation/main/static/readme_fig.png?token=GHSAT0AAAAAACTFBAFOPO3QHKOVJ26W4DU4ZWHSWFA)


## 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](https://github.com/amazon-science/azcausal).
1. [Data Synthesis](https://amazon-science.github.io/causal-validation/examples/basic/): We here show the full range of available functions for data generation.
2. [Placebo testing](https://amazon-science.github.io/causal-validation/examples/placebo_test/): Validate your model(s) using placebo tests.
3. [AZCausal notebook](https://amazon-science.github.io/causal-validation/examples/azcausal/): 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](https://hatch.pypa.io/latest/) (optional, but recommended for developers)

To install the latest stable version, run
`pip install causal-validation`
in your terminal.

### 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 causal-validation`
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 dev:test`

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "causal-validation",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "causal model, machine learning, synthetic data",
    "author": null,
    "author_email": "Thomas Pinder <pinthoma@amazon.nl>",
    "download_url": "https://files.pythonhosted.org/packages/45/5a/1e8fd1564308baeaeede6b1c45e3ec33a2c09835f45fbeb490ac042d4664/causal_validation-0.0.9.tar.gz",
    "platform": null,
    "description": "# Causal Validation\n\nThis package provides functionality to define your own causal data generation process\nand then simulate data from the process. Within the package, there is functionality to\ninclude complex components to your process, such as periodic and temporal trends, and\nall of these operations are fully composable with one another. \n\nA short example is given below\n```python\nfrom causal_validation import Config, simulate\nfrom causal_validation.effects import StaticEffect\nfrom causal_validation.plotters import plot\nfrom causal_validation.transforms import Trend, Periodic\nfrom causal_validation.transforms.parameter import UnitVaryingParameter\nfrom scipy.stats import norm\n\ncfg = Config(\n    n_control_units=10,\n    n_pre_intervention_timepoints=60,\n    n_post_intervention_timepoints=30,\n)\n\n# Simulate the base observation\nbase_data = simulate(cfg)\n\n# Apply a linear trend with unit-varying intercept\nintercept = UnitVaryingParameter(sampling_dist = norm(0, 1))\ntrend_component = Trend(degree=1, coefficient=0.1, intercept=intercept)\ntrended_data = trend_component(base_data)\n\n# Simulate a 5% lift in the treated unit's post-intervention data\neffect = StaticEffect(0.05)\ninflated_data = effect(trended_data)\n\n# Plot your data\nplot(inflated_data)\n```\n\n![](https://raw.githubusercontent.com/amazon-science/causal-validation/main/static/readme_fig.png?token=GHSAT0AAAAAACTFBAFOPO3QHKOVJ26W4DU4ZWHSWFA)\n\n\n## Examples\n\nTo supplement the above example, we have two more detailed notebooks which exhaustively\npresent and explain the functionalty in this package, along with how the generated data\nmay be integrated with [AZCausal](https://github.com/amazon-science/azcausal).\n1. [Data Synthesis](https://amazon-science.github.io/causal-validation/examples/basic/): We here show the full range of available functions for data generation.\n2. [Placebo testing](https://amazon-science.github.io/causal-validation/examples/placebo_test/): Validate your model(s) using placebo tests.\n3. [AZCausal notebook](https://amazon-science.github.io/causal-validation/examples/azcausal/): We here show how the generated data may be used within an AZCausal model.\n\n## Installation\n\nIn this section we guide the user through the installation of this package. We\ndistinguish here between _users_ of the package who seek to define their own data\ngenerating processes, and _developers_ who wish to extend the existing functionality of\nthe package.\n\n### Prerequisites\n\n- Python 3.10 or higher\n- [Hatch](https://hatch.pypa.io/latest/) (optional, but recommended for developers)\n\nTo install the latest stable version, run\n`pip install causal-validation`\nin your terminal.\n\n### For Users\n\n1. It's strongly recommended to use a virtual environment. Create and activate one using your preferred method before proceeding with the installation.\n2. Clone the package `git clone git@github.com:amazon-science/causal-validation.git`\n3. Enter the package's root directory `cd causal-validation`\n4. Install the package `pip install -e .`\n\n### For Developers\n\n1. Follow steps 1-3 from `For Users`\n2. Create a hatch environment `hatch env create`\n3. Open a hatch shell `hatch shell`\n4. Validate your installation by running `hatch run dev:test`\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A validation framework for causal models.",
    "version": "0.0.9",
    "project_urls": null,
    "split_keywords": [
        "causal model",
        " machine learning",
        " synthetic data"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6eca295c26cfd7845d9e66abb37fa4dac7d792043ff83c9a09455ffca170c9c4",
                "md5": "6bad834c78c804da12cc39329d83cfd3",
                "sha256": "262b800897b2e9ae12020de990b750caf55014f43c8954dc82d96bdd60baface"
            },
            "downloads": -1,
            "filename": "causal_validation-0.0.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6bad834c78c804da12cc39329d83cfd3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 23182,
            "upload_time": "2024-10-23T05:04:38",
            "upload_time_iso_8601": "2024-10-23T05:04:38.900816Z",
            "url": "https://files.pythonhosted.org/packages/6e/ca/295c26cfd7845d9e66abb37fa4dac7d792043ff83c9a09455ffca170c9c4/causal_validation-0.0.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "455a1e8fd1564308baeaeede6b1c45e3ec33a2c09835f45fbeb490ac042d4664",
                "md5": "09f227cc30d3719b1da0d9a75ba2cc33",
                "sha256": "d1300cac2af7591c76d9dfadf752130326514754eab1afdf582546916a5c5aad"
            },
            "downloads": -1,
            "filename": "causal_validation-0.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "09f227cc30d3719b1da0d9a75ba2cc33",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 16713,
            "upload_time": "2024-10-23T05:04:40",
            "upload_time_iso_8601": "2024-10-23T05:04:40.907713Z",
            "url": "https://files.pythonhosted.org/packages/45/5a/1e8fd1564308baeaeede6b1c45e3ec33a2c09835f45fbeb490ac042d4664/causal_validation-0.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-23 05:04:40",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "causal-validation"
}
        
Elapsed time: 0.55344s