Skip to main content

SDK for EconCausalAI - Causal Discovery and Economic Simulation with Bootstrap Uncertainty

Project description

EconCausalAI Python SDK

Production-ready SDK for causal discovery and economic policy simulation with bootstrap uncertainty quantification.

PyPI version Python 3.8+

Features

Causal Discovery - Discover cause-effect relationships from economic data ✅ Bootstrap Uncertainty - Get confidence intervals for all causal relationships ✅ Agent-Based Simulation - Simulate policy impacts with 1000+ micro agents ✅ Policy Optimization - Find optimal policies using RL ✅ 2930+ Curated Datasets - Access pre-processed economic data

Installation

pip install econcausal

Quick Start

Causal Discovery with Confidence Intervals

from econcausal import EconCausalClient
import pandas as pd

# Initialize client
client = EconCausalClient(
    base_url="http://localhost:8001/api/v1"  # Or your production URL
)

# Load your data
data = pd.read_csv("economic_data.csv")

# Discover causal relationships WITH bootstrap confidence
result = client.causal.discover(
    data=data,
    algorithm="pc_algorithm",
    use_bootstrap=True,
    n_bootstrap=50  # 50 iterations for confidence intervals
)

# Each edge has confidence metrics
for edge in result['graph']['edges']:
    print(f"{edge['source']}{edge['target']}")
    print(f"  Confidence: {edge.get('bootstrap_frequency', 'N/A'):.2f}")
    print(f"  95% CI: {edge.get('confidence_interval', 'N/A')}")

Policy Simulation

# Simulate interest rate policy
result = client.simulation.run(
    causal_graph=result['graph'],
    policy={
        "instrument": "interest_rate",
        "value": 0.08,  # 8% rate hike
        "time_horizon": 24
    },
    n_agents=2000,
    time_steps=24,
    initial_conditions={"inflation": 0.08, "unemployment": 0.04}
)

# Results include Central Bank + Government actions
print(f"Final inflation: {result['metrics']['inflation'][-1]:.2%}")
print(f"Final unemployment: {result['metrics']['unemployment'][-1]:.2%}")
print(f"Govt debt/GDP: {result['metrics']['government_debt_to_gdp'][-1]:.1%}")

API Reference

Causal Discovery

result = client.causal.discover(
    data: pd.DataFrame | List[Dict],
    algorithm: str = "pc_algorithm",  # or "notears"
    use_bootstrap: bool = False,
    n_bootstrap: int = 50
)

Returns graph with edges containing:

  • bootstrap_frequency: How often edge appears (0-1)
  • confidence_interval: [lower, upper] 95% CI
  • weight: Edge strength

Data Validation

validation = client.causal.validate_data(data)
# Returns: is_valid, errors, warnings, statistics

Examples

See examples/ directory:

  • quickstart.ipynb - Basic workflow
  • bootstrap.ipynb - Confidence intervals
  • simulation.ipynb - Policy analysis

Requirements

  • Python 3.8+
  • pandas, numpy, requests

License

MIT License

Changelog

v0.2.0 (2025-12-20)

✨ New: Bootstrap uncertainty, data validation, enhanced agents 🐛 Improved: Error handling, timeouts

v0.1.0 (2024-12-01)

  • Initial release

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

econcausal-0.2.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

econcausal-0.2.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file econcausal-0.2.0.tar.gz.

File metadata

  • Download URL: econcausal-0.2.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for econcausal-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c0fb6faf6794756931a93fd90a6e3b3b50f813c122d068f97365994d91d29147
MD5 a946e8f2cd3b382230cdefada9cbc84f
BLAKE2b-256 3422aa0584a43520be2dce1a75e157fc10f74c4d8484d50d8f91c3669e528640

See more details on using hashes here.

File details

Details for the file econcausal-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: econcausal-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for econcausal-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b428c93851da379aba52e29e8e3a3dbd927bbf58e0fb14043e40de4946163e0
MD5 670999555d306ab490467ecf5f466e78
BLAKE2b-256 51cc7006b794a6e1eaedce74e223546063cc78babd83fff991c5a621d3556ded

See more details on using hashes here.

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