Skip to main content

A Python library for quantitative reasoning.

Project description

formative

Python library for quantitative reasoning.

Requirements

  • Python 3.10+

Installation

pip install formative-ds

Docs

Comprehensive documentation is available at docs.getformative.dev.

Usage

Causal estimation

from formative.causal 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.

Decision rules

from formative.game import maximin, maximax, hurwicz, laplace, minimax

outcomes = {
    "stocks": {"recession": -20, "stagnation":  5, "growth": 30},
    "bonds":  {"recession":   5, "stagnation":  5, "growth":  7},
    "cash":   {"recession":   2, "stagnation":  2, "growth":  2},
}

maximin(outcomes).solve()        # safest choice (best worst case)
maximax(outcomes).solve()        # most optimistic (best best case)
hurwicz(outcomes, alpha=0.5).solve()  # blend of optimism and pessimism
laplace(outcomes).solve()        # highest average payoff
minimax(outcomes).solve()        # lowest worst-case regret

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.causal 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-2.0.0.tar.gz (151.9 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-2.0.0-py3-none-any.whl (59.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for formative_ds-2.0.0.tar.gz
Algorithm Hash digest
SHA256 0307aabb554a19ae335d8b4664b9f3ed50f14b6da94328a081a3e0d62d3e0b36
MD5 fb3d3006f7fe3a77a154e1242585df0e
BLAKE2b-256 16517e08007ec5d310cd3eb6af930da67b2c214e553b6e84fa6455955395e0b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for formative_ds-2.0.0.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-2.0.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for formative_ds-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c09c111240291ad8384d0d1278c4db5e3dea770fcce1b50791edd6646548cf6b
MD5 a5197ada5e4a0ce0ed6ead1dabbe2e04
BLAKE2b-256 47043064a5b974add9d73173d786c89a4e0561dcc78a7095c04a997f76f67cf3

See more details on using hashes here.

Provenance

The following attestation bundles were made for formative_ds-2.0.0-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