Metadata-Version: 2.4
Name: cohera
Version: 0.1.0
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Summary: Hierarchical coherence: forecast reconciliation (OLS, WLS, MinTrace), conformal prediction, community detection (Leiden, Louvain).
Keywords: hierarchical,reconciliation,conformal-prediction,leiden,community-detection
Author-email: Arc <attobop@gmail.com>
License: MIT OR Apache-2.0
Requires-Python: >=3.8
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Documentation, https://docs.rs/sheaf
Project-URL: Homepage, https://github.com/arclabs561/sheaf
Project-URL: Repository, https://github.com/arclabs561/sheaf

# cohera

Python bindings for [sheaf](https://docs.rs/sheaf) (Rust).

Forecast reconciliation (OLS, WLS, MinTrace), hierarchical conformal prediction,
and community detection (Leiden, Louvain, Label Propagation).

## Install

```
pip install cohera
```

## Usage

### Reconciliation

```python
import cohera

# 2-level hierarchy: 1 root + 3 leaves
s = cohera.simple_star_matrix(3)

# Incoherent base forecasts
base = [12.0, 3.0, 4.0, 5.0]

# OLS reconciliation
reconciled = cohera.reconcile(s, base, method="ols")
# reconciled[0] == reconciled[1] + reconciled[2] + reconciled[3]
```

### Conformal prediction

```python
hc = cohera.HierarchicalConformal(s, method="ols")
hc.calibrate(y_calib, y_hat_calib, alpha=0.1)
lower, upper = hc.predict(y_hat)
```

### Community detection

```python
edges = [(0, 1, 1.0), (1, 2, 1.0), (0, 2, 1.0)]
communities = cohera.leiden(edges, n_nodes=3, resolution=1.0)
```

### Clustering metrics

```python
nmi = cohera.nmi([0, 0, 1, 1], [0, 0, 1, 1])  # 1.0
ari = cohera.ari([0, 0, 1, 1], [0, 0, 1, 1])  # 1.0
```

## License

MIT OR Apache-2.0

