Skip to main content

A Python library for causal effect estimation.

Project description

formative

Python library for causal effect estimation. You declare your causal assumptions as a DAG before choosing an estimation method, making identification explicit rather than implicit.

Requirements

  • Python 3.10+

Installation

pip install formative-ds

Docs

Comprehensive documentation is available at docs.getformative.dev.

Usage

from formative import DAG, OLSObservational

dag = DAG()
dag.assume("ability").causes("education", "income")
dag.assume("education").causes("income")

result = OLSObservational(
    dag,
    treatment="education",
    outcome="income"
).fit(df)

print(result.summary())

Confounders declared in the DAG are controlled for automatically. If a confounder is absent from the dataframe, an IdentificationError is raised before any estimation runs. See online documentation at docs.getformative.dev for more examples and details.

Local development

Requires uv.

git clone https://github.com/maxpagels/formative
cd formative
uv sync --dev

This creates a .venv, installs all dependencies, and installs the package in editable mode.

Releasing a new version

uvx bump-my-version bump patch   # 0.1.0 → 0.1.1 (bug fixes)
uvx bump-my-version bump minor   # 0.1.0 → 0.2.0 (new features)
uvx bump-my-version bump major   # 0.1.0 → 1.0.0 (breaking changes)
git push --follow-tags            # triggers publish to PyPI

Running tests

uv run pytest

Importing without installing

To use formative from a script outside this repo without installing it, either prepend the path at runtime:

import sys
sys.path.insert(0, "/path/to/formative")

from formative import DAG, OLSObservational

Or set PYTHONPATH before running:

PYTHONPATH=/path/to/formative python your_script.py

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

formative_ds-0.2.1.tar.gz (134.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

formative_ds-0.2.1-py3-none-any.whl (44.8 kB view details)

Uploaded Python 3

File details

Details for the file formative_ds-0.2.1.tar.gz.

File metadata

  • Download URL: formative_ds-0.2.1.tar.gz
  • Upload date:
  • Size: 134.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for formative_ds-0.2.1.tar.gz
Algorithm Hash digest
SHA256 7d7a0962c4d943376e387439edd3a1db30da25a183581155257e767aa4086ab0
MD5 7ab8886fc86368130ca3c3d8f669b04c
BLAKE2b-256 790d9f1ce14a2dcd7bb4a2bf27f1400b6da2130632e8a5e4f9a61a3a9f40c56b

See more details on using hashes here.

Provenance

The following attestation bundles were made for formative_ds-0.2.1.tar.gz:

Publisher: publish.yml on maxpagels/formative

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file formative_ds-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: formative_ds-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 44.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for formative_ds-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6ddeda49eb66cbd9433a3858b81d09764fe04ab6230084b8e358db1c6224cc8a
MD5 2e286411a4c211803d33d630832070db
BLAKE2b-256 25fb3673c653a60b51f43a6dd1cbe3f84b8d1b7e29efadd1151e990d413e403b

See more details on using hashes here.

Provenance

The following attestation bundles were made for formative_ds-0.2.1-py3-none-any.whl:

Publisher: publish.yml on maxpagels/formative

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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