occam-nim
A Nim 2.x implementation of OCCAM (Organizational Complexity Computation and Modeling), a Reconstructability Analysis (RA) tool for discovering structure in categorical datasets using information theory and graph theory.
What is Reconstructability Analysis?
RA is a discrete multivariate modeling approach that identifies which variables are related, which are independent, and their combined predictive power. It embodies Occam's Razor by searching for the simplest model that captures important data relationships—useful for exploratory analysis, feature selection, structure discovery, and interpretable modeling.
Features
- Model fitting: entropy, transmission, degrees of freedom, likelihood ratio, AIC, BIC
- Search algorithms: loopless, full, disjoint, and chain strategies with parallel execution
- Decomposable models: exact inference via junction tree and belief propagation
- Loop models: Iterative Proportional Fitting (IPF) for non-decomposable structures
- Directed systems: conditional entropy, confusion matrix, prediction accuracy
- Multiple interfaces: library API, CLI tool, web server, and MCP server
Installation
As a Nim library:
nimble install occam
From source:
git clone https://github.com/Gooseus/occam-nim
cd occam-nim
nimble install -d
nimble test
Usage
CLI for CSV analysis:
./bin/cli analyze-csv -i data.csv
./bin/cli search -i data.json --direction up --width 5
Note: This is a work in progress. Core library and CLI are functional and validated against original OCCAM, but APIs may change before v1.0.