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.
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% CIweight: Edge strength
Data Validation
validation = client.causal.validate_data(data)
# Returns: is_valid, errors, warnings, statistics
Examples
See examples/ directory:
quickstart.ipynb- Basic workflowbootstrap.ipynb- Confidence intervalssimulation.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0fb6faf6794756931a93fd90a6e3b3b50f813c122d068f97365994d91d29147
|
|
| MD5 |
a946e8f2cd3b382230cdefada9cbc84f
|
|
| BLAKE2b-256 |
3422aa0584a43520be2dce1a75e157fc10f74c4d8484d50d8f91c3669e528640
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b428c93851da379aba52e29e8e3a3dbd927bbf58e0fb14043e40de4946163e0
|
|
| MD5 |
670999555d306ab490467ecf5f466e78
|
|
| BLAKE2b-256 |
51cc7006b794a6e1eaedce74e223546063cc78babd83fff991c5a621d3556ded
|