Skip to main content

COREX-Causal: Causal Origin Resolution and Empirical eXamination โ€” Framework for Robust Causal Discrimination

Project description

COREX Logo

COREX

Causal Origin Resolution and Empirical eXamination

An Autonomous Multi-Stage Framework for Robust Causal Discrimination in Data-Driven AI Systems


PyPI version PyPI downloads Python versions DOI OSF Preregistration ORCID License: MIT Series Website


๐Ÿ“Œ Overview

COREX is a deterministic, graph-free, model-agnostic computational framework that treats causality as an empirically testable robustness property rather than an assumed structural characteristic.

"Causality is not assumed, inferred, or interpreted โ€” it is survived or rejected under systematic perturbation tests."

Contemporary machine learning systems routinely exploit shortcut correlations embedded in training distributions โ€” associations that collapse the moment data distribution shifts, feature encodings change, or interventions are applied. COREX provides a principled four-axis audit pipeline to classify any observed X โ†’ Y relationship as:

Label COREX Score Meaning
๐ŸŸข CAUSAL โ‰ฅ 0.80 Survives all four evaluation axes
๐ŸŸก SPURIOUS 0.50 โ€“ 0.79 Breaks under domain shift or intervention
๐Ÿ”ด REPRESENTATION ARTIFACT < 0.50 Exists only as a function of encoding choice

๐Ÿ—‚๏ธ Table of Contents


โœจ Key Features

  • Four-module evaluation pipeline โ€” Statistical Stability, Representation Invariance, Domain Robustness, Intervention Consistency
  • No prior causal graph required โ€” purely empirical robustness testing
  • Model-agnostic โ€” works as a meta-evaluation layer atop any learned relationship
  • Calibrated causal scoring โ€” weighted fusion with interpretable decision thresholds
  • Optional learnable inference layer โ€” adaptive calibration for high-dimensional settings
  • Validated on biomedical signals โ€” vagus nerve electrophysiology, LPS/SIRS/CAR-T models
  • Full open-source distribution โ€” available across 11 platforms

๐Ÿ“ Project Structure

COREX/
โ”‚
โ”œโ”€โ”€ corex/                          # Core Python package
โ”‚   โ”œโ”€โ”€ __init__.py                 # Package entry point & public API
โ”‚   โ”œโ”€โ”€ pipeline.py                 # Main COREX evaluation pipeline
โ”‚   โ”œโ”€โ”€ score.py                    # Causal scoring function & decision logic
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ modules/                    # Evaluation modules
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ statistical.py          # Module 1: Statistical Stability (S)
โ”‚   โ”‚   โ”œโ”€โ”€ representation.py       # Module 2: Representation Invariance (R)
โ”‚   โ”‚   โ”œโ”€โ”€ domain.py               # Module 3: Domain Robustness (D)
โ”‚   โ”‚   โ””โ”€โ”€ intervention.py         # Module 4: Intervention Consistency (I)
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ learnable/                  # Optional learnable inference layer
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ meta_scorer.py          # Adaptive MLP weight estimator
โ”‚   โ”‚   โ””โ”€โ”€ weights/                # Pre-trained weight checkpoints
โ”‚   โ”‚       โ””โ”€โ”€ default.pt
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ utils/                      # Shared utilities
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ”œโ”€โ”€ transforms.py           # Feature transformation library (ฯ† family)
โ”‚       โ”œโ”€โ”€ environments.py         # Environment construction & partitioning
โ”‚       โ”œโ”€โ”€ counterfactual.py       # Intervention simulation engine
โ”‚       โ””โ”€โ”€ metrics.py              # KL divergence, KS tests, CV, etc.
โ”‚
โ”œโ”€โ”€ benchmarks/                     # Synthetic ground-truth benchmarks
โ”‚   โ”œโ”€โ”€ generators/
โ”‚   โ”‚   โ”œโ”€โ”€ causal_chain.py         # Class C: true causal chains Xโ†’Yโ†’Z
โ”‚   โ”‚   โ”œโ”€โ”€ spurious_confound.py    # Class S: latent confounder Hโ†’X, Hโ†’Y
โ”‚   โ”‚   โ””โ”€โ”€ artifact_encoding.py    # Class A: encoding-dependent associations
โ”‚   โ”œโ”€โ”€ run_benchmarks.py           # Full benchmark evaluation script
โ”‚   โ””โ”€โ”€ results/                    # Pre-computed benchmark outputs
โ”‚       โ””โ”€โ”€ synthetic_1500.json
โ”‚
โ”œโ”€โ”€ validation/                     # Real-world biomedical validation
โ”‚   โ”œโ”€โ”€ vagus_nerve/
โ”‚   โ”‚   โ”œโ”€โ”€ preprocess.py           # Electrophysiology signal preprocessing
โ”‚   โ”‚   โ”œโ”€โ”€ feature_extraction.py   # Wavelet, PCA, CNN embedding extraction
โ”‚   โ”‚   โ””โ”€โ”€ evaluate.py             # COREX evaluation on vagalโ€“cytokine data
โ”‚   โ””โ”€โ”€ results/
โ”‚       โ””โ”€โ”€ biomedical_validation.json
โ”‚
โ”œโ”€โ”€ examples/                       # Usage examples & tutorials
โ”‚   โ”œโ”€โ”€ quickstart.py               # Minimal working example
โ”‚   โ”œโ”€โ”€ synthetic_demo.ipynb        # Jupyter notebook: synthetic datasets
โ”‚   โ”œโ”€โ”€ biomedical_demo.ipynb       # Jupyter notebook: biomedical signals
โ”‚   โ””โ”€โ”€ custom_weights.py           # Custom weight configuration example
โ”‚
โ”œโ”€โ”€ tests/                          # Unit and integration tests
โ”‚   โ”œโ”€โ”€ test_statistical.py
โ”‚   โ”œโ”€โ”€ test_representation.py
โ”‚   โ”œโ”€โ”€ test_domain.py
โ”‚   โ”œโ”€โ”€ test_intervention.py
โ”‚   โ”œโ”€โ”€ test_pipeline.py
โ”‚   โ””โ”€โ”€ test_scoring.py
โ”‚
โ”œโ”€โ”€ docs/                           # Documentation source
โ”‚   โ”œโ”€โ”€ architecture.md             # Pipeline architecture reference
โ”‚   โ”œโ”€โ”€ modules.md                  # Per-module API documentation
โ”‚   โ”œโ”€โ”€ scoring.md                  # Scoring function & threshold calibration
โ”‚   โ””โ”€โ”€ api_reference.md            # Full Python API reference
โ”‚
โ”œโ”€โ”€ paper/                          # Research paper artifacts
โ”‚   โ”œโ”€โ”€ COREX_Research_Paper.pdf    # Published paper (PDF)
โ”‚   โ”œโ”€โ”€ COREX_Research_Paper.docx   # Editable Word version
โ”‚   โ””โ”€โ”€ figures/                    # Paper figures & diagrams
โ”‚       โ””โ”€โ”€ pipeline_diagram.svg
โ”‚
โ”œโ”€โ”€ .gitlab-ci.yml                  # GitLab CI/CD pipeline
โ”œโ”€โ”€ .github/                        # GitHub Actions workflows
โ”‚   โ””โ”€โ”€ workflows/
โ”‚       โ”œโ”€โ”€ tests.yml
โ”‚       โ””โ”€โ”€ publish.yml
โ”œโ”€โ”€ pyproject.toml                  # Build system configuration
โ”œโ”€โ”€ setup.cfg                       # Package metadata
โ”œโ”€โ”€ requirements.txt                # Runtime dependencies
โ”œโ”€โ”€ requirements-dev.txt            # Development dependencies
โ”œโ”€โ”€ CHANGELOG.md                    # Version history
โ”œโ”€โ”€ CONTRIBUTING.md                 # Contribution guidelines
โ”œโ”€โ”€ CODE_OF_CONDUCT.md
โ”œโ”€โ”€ AUTHORS.md                      # Author and contributor registry
โ”œโ”€โ”€ LICENSE                         # MIT License
โ””โ”€โ”€ README.md                       # This file

๐Ÿš€ Quick Start

Installation

# Install from PyPI
pip install corex-causal-causal-causal-causal

# Install from source
git clone https://github.com/gitdeeper12/COREX.git
cd COREX
pip install -e .

Minimal Example

from corex import CausalEvaluator

# Initialize the evaluator
evaluator = CausalEvaluator()

# Load your data
# X: feature array of shape (n_samples, n_features)
# Y: target array of shape (n_samples,)
result = evaluator.evaluate(X, Y)

print(result.label)          # "CAUSAL" | "SPURIOUS" | "REPRESENTATION_ARTIFACT"
print(result.corex_score)    # float in [0, 1]
print(result.breakdown)      # {"S": 0.91, "R": 0.88, "I": 0.85, "D": 0.90}
print(result.failure_modes)  # list of detected failure modes (if any)

With Custom Weights

from corex import CausalEvaluator

evaluator = CausalEvaluator(
    weights={
        "statistical": 0.25,
        "representation": 0.25,
        "intervention": 0.30,
        "domain": 0.20
    }
)
result = evaluator.evaluate(X, Y, environments=env_labels)

With Learnable Inference Layer

from corex import CausalEvaluator
from corex.learnable import MetaScorer

meta = MetaScorer.from_pretrained("default")
evaluator = CausalEvaluator(meta_scorer=meta)
result = evaluator.evaluate(X, Y)

๐Ÿงฉ COREX Pipeline

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Raw Data  D                       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                     โ”‚
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚             โ”‚              โ”‚
       โ–ผ             โ–ผ              โ–ผ
  Statistical    Representation   Domain Shift
    Module          Module          Module
   (score S)      (score R)       (score D)
       โ”‚             โ”‚              โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                     โ”‚
                     โ–ผ
             Intervention Engine
                  (score I)
                     โ”‚
                     โ–ผ
            Causal Scoring Layer
         COREX = wโ‚S + wโ‚‚R + wโ‚ƒI + wโ‚„D
                     โ”‚
                     โ–ผ
           โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
           โ”‚  Final Decision  โ”‚
           โ”‚  ๐ŸŸข CAUSAL       โ”‚
           โ”‚  ๐ŸŸก SPURIOUS     โ”‚
           โ”‚  ๐Ÿ”ด ARTIFACT     โ”‚
           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Module Descriptions

# Module Formula Description
1 Statistical Stability (S) S = 1 - mean KL[P(Y|X,Dโ‚) โ€– P(Y|X,Dโ‚‚)] Cross-partition conditional invariance
2 Representation Invariance (R) R = 1 - (1/|ฮฆ|) ฮฃ โ€–P(Y|X) - P(Y|ฯ†(X))โ€–โ‚ Stability under feature transformations
3 Intervention Consistency (I) I = Consistency(do(X=xโ‚)โ†’Yโ‚, do(X=xโ‚‚)โ†’Yโ‚‚) Causal effect direction & magnitude stability
4 Domain Robustness (D) D = 1 - CV(P(Y|X, e)) over e โˆˆ E Cross-environment generalization

๐Ÿ“Š Scoring Function

COREX = wโ‚ยทS + wโ‚‚ยทR + wโ‚ƒยทI + wโ‚„ยทD

Default weights:
  wโ‚ = 0.25  (Statistical Stability)
  wโ‚‚ = 0.25  (Representation Invariance)
  wโ‚ƒ = 0.30  (Intervention Consistency)   โ† highest weight: closest proxy to true causality
  wโ‚„ = 0.20  (Domain Robustness)

Decision thresholds:

Score Range Classification Condition
COREX โ‰ฅ 0.80 ๐ŸŸข CAUSAL All modules stable; intervention confirmed
0.50 โ‰ค COREX < 0.80 ๐ŸŸก SPURIOUS CORRELATION Domain shift or intervention failure detected
COREX < 0.50 ๐Ÿ”ด REPRESENTATION ARTIFACT Representation invariance fails

๐ŸŒ Platforms & Mirrors

Platform URL Role
๐Ÿ™ GitHub (Primary) github.com/gitdeeper12/COREX Source code, issues, PRs
๐ŸฆŠ GitLab (Mirror) gitlab.com/gitdeeper12/COREX CI/CD mirror
๐Ÿชฃ Bitbucket (Mirror) bitbucket.org/gitdeeper-12/COREX Enterprise mirror
๐Ÿ”๏ธ Codeberg (Mirror) codeberg.org/gitdeeper12/COREX Open-source community
๐Ÿ“ฆ PyPI pypi.org/project/corex-causal-causal Python package distribution
๐Ÿ”ฌ Zenodo doi.org/10.5281/zenodo.20351233 Citable DOI, paper & data
๐Ÿ“‹ OSF Project osf.io/3ABZF Research project registry
๐Ÿ“ OSF Preregistration doi.org/10.17605/OSF.IO/3ABZF Pre-registered study protocol
๐ŸŒ Website corex.netlify.app Live documentation & dashboard
๐Ÿง‘โ€๐Ÿ”ฌ ORCID orcid.org/0009-0003-8903-0029 Researcher identity
๐Ÿ—„๏ธ Internet Archive archive.org/details/osf-registrations-3ABZF Permanent archival copy

๐ŸŒ Official Website Pages

Page URL
Homepage corex.netlify.app
Dashboard corex.netlify.app/dashboard
Results corex.netlify.app/results
Documentation corex.netlify.app/documentation

๐Ÿ”„ Clone & Download

Git Clone

# GitHub (Primary)
git clone https://github.com/gitdeeper12/COREX.git

# GitLab (Mirror)
git clone https://gitlab.com/gitdeeper12/COREX.git

# Bitbucket (Mirror)
git clone https://bitbucket.org/gitdeeper-12/COREX.git

# Codeberg (Mirror)
git clone https://codeberg.org/gitdeeper12/COREX.git

Direct ZIP Download

Source Link
GitHub COREX-main.zip
GitLab COREX-main.zip
Bitbucket COREX-main.zip
Codeberg COREX-main.zip
PyPI files pypi.org/project/corex-causal-causal/#files
Zenodo record doi.org/10.5281/zenodo.20351233

๐Ÿ“– Citation

If COREX contributes to your research, please cite using one of the following formats.

๐Ÿ“ฆ PyPI Package

@software{baladi2026corex_pypi,
  author       = {Baladi, Samir},
  title        = {{COREX}: Causal Origin Resolution and Empirical eXamination},
  year         = {2026},
  version      = {1.0.0},
  publisher    = {Python Package Index},
  url          = {https://pypi.org/project/corex-causal-causal-causal-causal},
  note         = {Python package, MIT License}
}

๐Ÿ”ฌ Zenodo Archive (Paper & Data)

@dataset{baladi2026corex_zenodo,
  author       = {Baladi, Samir},
  title        = {{COREX}: Causal Origin Resolution and Empirical eXamination โ€” Research Paper and Data},
  year         = {2026},
  publisher    = {Zenodo},
  version      = {1.0.0},
  doi          = {10.5281/zenodo.20351233},
  url          = {https://doi.org/10.5281/zenodo.20351233},
  series       = {BIO-MED-02}
}

๐Ÿ“ OSF Preregistration

@misc{baladi2026corex_osf,
  author       = {Baladi, Samir},
  title        = {{COREX} Framework: Pre-registered Study Protocol for Causal Discrimination in Data-Driven Models},
  year         = {2026},
  publisher    = {Open Science Framework},
  doi          = {10.17605/OSF.IO/3ABZF},
  url          = {https://doi.org/10.17605/OSF.IO/3ABZF},
  note         = {OSF Preregistration}
}

๐Ÿ“„ Research Paper

@article{baladi2026corex,
  author       = {Baladi, Samir},
  title        = {{COREX}: An Autonomous Multi-Stage Framework for Robust Causal Discrimination in Data-Driven {AI} Systems},
  year         = {2026},
  month        = {May},
  series       = {BIO-MED-02},
  version      = {1.0.0},
  doi          = {10.5281/zenodo.20351233},
  url          = {https://doi.org/10.5281/zenodo.20351233},
  note         = {Ronin Institute / Rite of Renaissance}
}

APA (inline)

Baladi, S. (2026). COREX: An Autonomous Multi-Stage Framework for Robust Causal Discrimination in Data-Driven AI Systems (Version 1.0.0, Series BIO-MED-02). Zenodo. https://doi.org/10.5281/zenodo.20351233


๐Ÿ“œ License

This project is licensed under the MIT License โ€” see the LICENSE file for details.

MIT License

Copyright (c) 2026 Samir Baladi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction...

๐Ÿ‘ค Author

Samir Baladi Interdisciplinary AI Researcher โ€” Neural Engineering & Biomedical AI Ronin Institute / Rite of Renaissance

Contact Link
๐Ÿ“ง Email gitdeeper@gmail.com
๐Ÿง‘โ€๐Ÿ”ฌ ORCID 0009-0003-8903-0029
๐Ÿ™ GitHub github.com/gitdeeper12
๐ŸŒ Website corex.netlify.app

Series BIO-MED-02 ยท Version 1.0.0 ยท May 2026

DOI PyPI License: MIT

"Causality is not assumed โ€” it is survived."

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

corex_causal-1.0.0.tar.gz (41.7 kB view details)

Uploaded Source

Built Distribution

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

corex_causal-1.0.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file corex_causal-1.0.0.tar.gz.

File metadata

  • Download URL: corex_causal-1.0.0.tar.gz
  • Upload date:
  • Size: 41.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: COREX-Causal-Uploader/1.0

File hashes

Hashes for corex_causal-1.0.0.tar.gz
Algorithm Hash digest
SHA256 41cbd4d1a8abe5d6bf21addcd8d2b1ccc44cd4705b8ece296897d006483bb25d
MD5 65320b48874050cabd8bf1787b25226d
BLAKE2b-256 75a42162672cdf9692cb75c32581e97145c2db0dede67e5e78bfeb2a3489f96c

See more details on using hashes here.

File details

Details for the file corex_causal-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: corex_causal-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: COREX-Causal-Uploader/1.0

File hashes

Hashes for corex_causal-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5cd1cad5f74df012b963834059c6952f6fc39f8328928bf65d1a6bfed667152a
MD5 57a760418d4359c3e7b9ee4756d86ccc
BLAKE2b-256 46c9eb9283ad4657a1bfcde6265e869836ea8ac394c9e55ead72bca41af5707f

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