OCCAM Reconstructability Analysis Tools
Project description
PyOccam
Python bindings for OCCAM Reconstructability Analysis
What is PyOccam?
PyOccam wraps the OCCAM Reconstructability Analysis tools in a modern Python package. It provides information-theoretic modeling for categorical data, useful for:
- Environmental modeling (landslides, wildfires)
- Biomedical research (disease risk factors)
- Social science and survey analysis
- Any domain with discrete/categorical variables
OCCAM discovers significant variable relationships while emphasizing interpretability over black-box prediction.
Installation
pip install pyoccam
Quick Start
import pyoccam
# Load built-in dataset
data = pyoccam.load_dementia()
print(f"Loaded {data.n_samples} samples, {data.n_features} features")
# Run search to find best model
manager = data.manager
report = manager.generate_search_report("loopless-up", levels=5, width=3)
print(report)
# Get best model by BIC
best = manager.get_best_model_by_bic()
print(f"Best model: {best}")
# Generate fit report with confusion matrix
fit_report = manager.generate_fit_report(best, target_state="0")
print(fit_report)
# Get confusion matrix as dictionary
cm = manager.get_confusion_matrix(best, target_state="0")
print(f"Accuracy: {cm['train_accuracy']:.1%}")
Convert Your Own CSV Data
import pyoccam
# Convert CSV to OCCAM format with train/test split
output_file, data = pyoccam.make_occam_input_from_csv(
"mydata.csv",
test_split=0.2, # 20% held out for validation
random_state=42, # Reproducible split
max_cardinality=20, # Exclude columns with >20 unique values
dv_column="target", # Specify dependent variable
exclude_columns=["ID", "Name"] # Always exclude these
)
# Analyze - now with train AND test metrics!
best = data.quick_search()
cm = data.manager.get_confusion_matrix(best, target_state="0")
print(f"Train accuracy: {cm['train_accuracy']:.1%}")
print(f"Test accuracy: {cm['test_accuracy']:.1%}")
Or from the command line:
# With 20% test split
python -m pyoccam csv2occam mydata.csv --test-split 0.2 --exclude ID,Name
Model Selection Methods
# Different criteria for "best" model:
best_bic = manager.get_best_model_by_bic() # Most parsimonious (recommended)
best_aic = manager.get_best_model_by_aic() # Less penalty for complexity
best_info = manager.get_best_model_by_information() # Highest info, alpha < 0.05
Built-in Datasets
data = pyoccam.load_dementia() # Alzheimer's disease risk factors
data = pyoccam.load_landslides() # Geological hazard data
data = pyoccam.load_data("file.txt") # Any OCCAM format file
Search Types
"loopless-up"- Bottom-up search, no feedback loops (recommended for directed systems)"loopless-down"- Top-down search, no loops"full-up"- Bottom-up with loops allowed"full-down"- Top-down with loops allowed
Links
- Practical Guide: PRACTICAL_GUIDE.md - Tips from real projects
- OCCAM Manual: PDF - Complete theory & reference
- Source Code: github.com/occam-ra/occam
- Web Interface: occam.hsd.pdx.edu
License
GPL v3 - See LICENSE file
Credits
OCCAM was developed at Portland State University by Prof. Martin Zwick and contributors including Ken Willett, Joe Fusion, and H. Forrest Alexander. Python bindings by David Percy.
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 Distributions
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 pyoccam-0.9.4.tar.gz.
File metadata
- Download URL: pyoccam-0.9.4.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a4f7980ab618d372091fbc115a90f8c1d466b923a527afcb861d7ca70866f20
|
|
| MD5 |
55c4f6ffc97a5d2b813861dca622a709
|
|
| BLAKE2b-256 |
f45a96294afa4ee7752844d3984d3e8bc300a63a5e0310845945e34291877111
|
File details
Details for the file pyoccam-0.9.4-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: pyoccam-0.9.4-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18c6ec7f8415ef618bd3b56a1d8c0e91a1f7a56104857a77ed5615e46a6ae64b
|
|
| MD5 |
c982ce24e6c9d6b4246630c59eeaf096
|
|
| BLAKE2b-256 |
f13bee942f93df349600df75bd56afbd5bcb8d838716107a450245512126ef85
|
File details
Details for the file pyoccam-0.9.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyoccam-0.9.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d5604424d24503d885f27b64f519d481d1f30914e55dd5682837e3641eb1eb7
|
|
| MD5 |
e2ea02a8f5101614f4589814429382af
|
|
| BLAKE2b-256 |
b89380a70a85385ed5a8d3ccc2a1c0b02833fbd67ac0d297bad12105d5b92020
|
File details
Details for the file pyoccam-0.9.4-cp312-cp312-macosx_10_9_universal2.whl.
File metadata
- Download URL: pyoccam-0.9.4-cp312-cp312-macosx_10_9_universal2.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.12, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
325047a9fc9083f0133851df114520f59ba637507307adf5156165e53d1eb0e1
|
|
| MD5 |
93dd20e951dcc115333624751219c103
|
|
| BLAKE2b-256 |
09c4016a8a1c66294ed588bd3660b6e6f483fe378363214dddab47cd95b3619a
|
File details
Details for the file pyoccam-0.9.4-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: pyoccam-0.9.4-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8935218d5793b1ceda29eafa74ee5d9045e4f47b57c45948fe4b1f0bcf3e324b
|
|
| MD5 |
a863a8e062377e7a291034de4538aede
|
|
| BLAKE2b-256 |
068cb2bfda820845b52c007d681c2ffb014dd785d8504f27c616182ea3c4971e
|
File details
Details for the file pyoccam-0.9.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyoccam-0.9.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.2 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0de90228a7f6ef2699b2413b3ed34ea6da394de869525f3f018197d2fd45477a
|
|
| MD5 |
6f402da8b87b9d34ec40d67effc37137
|
|
| BLAKE2b-256 |
13b9f6a78c7037af6306279ceb7f6463a1d2d2aa9c9b268b9d75c356d454b65a
|
File details
Details for the file pyoccam-0.9.4-cp311-cp311-macosx_10_9_universal2.whl.
File metadata
- Download URL: pyoccam-0.9.4-cp311-cp311-macosx_10_9_universal2.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.11, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6aae3b0427810a0e72c97790799d6581d916fa7af1c1fd6edade6dcc235101cf
|
|
| MD5 |
8739110f420b843a761994cbbec20cc2
|
|
| BLAKE2b-256 |
2c41a6a22394a073a42304b97bba47d8db46af2ff47e4012dc02b591f1284db2
|
File details
Details for the file pyoccam-0.9.4-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: pyoccam-0.9.4-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71c3bb880a5e4413c96ed03a9a1b2e137d16e2943b4bbb99fb3c67800c28f8bf
|
|
| MD5 |
d8628793df83380028708d189d443d0c
|
|
| BLAKE2b-256 |
4a35199bb5e9835d58d871363dceac3c6bb30450111e3655815d2046bd2d3df3
|
File details
Details for the file pyoccam-0.9.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyoccam-0.9.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.2 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
048a3b43a7f4fc9abf23223c7aef8f4967e5ae9f040ff9dd5b97a476a38415d9
|
|
| MD5 |
b3998548fa571d1b99760620a43e202c
|
|
| BLAKE2b-256 |
4b864cf74d58d77e478e4c309778eb202aa63338cabab85d4b3fd5017bea7f58
|
File details
Details for the file pyoccam-0.9.4-cp310-cp310-macosx_10_9_universal2.whl.
File metadata
- Download URL: pyoccam-0.9.4-cp310-cp310-macosx_10_9_universal2.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.10, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26a4bcbb9b7a48757dc0db526f8368a45bea08315474825f40ae14f9106e8caa
|
|
| MD5 |
6901b28e90f334bc3d9f1b1ff2f522a2
|
|
| BLAKE2b-256 |
86ad94e58c0673783d0f63021707849bc51bf3e3f7da8932d447178cdaadef3a
|
File details
Details for the file pyoccam-0.9.4-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: pyoccam-0.9.4-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67976aa57195306f1680139489bff7a10ee7cbc6032bc9f8cfbec7d4e26e02f2
|
|
| MD5 |
746befd4939a67dee7e493c555dd98c5
|
|
| BLAKE2b-256 |
155b9e8c2478e1ec2b6dea4c863fbbe4317506981c51896bad425eb8844114e0
|
File details
Details for the file pyoccam-0.9.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyoccam-0.9.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.2 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3805c43abb9f7099812b4d046d57834bf063e35f5812e3da0e4afbe5b885c7c
|
|
| MD5 |
60e331dcaba3bdd77c981cb229390867
|
|
| BLAKE2b-256 |
40f9f6a29433588c0d666eb3e8439972b564a2e2df93f82015df1dfd39ef0e5c
|
File details
Details for the file pyoccam-0.9.4-cp39-cp39-macosx_10_9_universal2.whl.
File metadata
- Download URL: pyoccam-0.9.4-cp39-cp39-macosx_10_9_universal2.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.9, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a00bae48ebc696e91c41f2aa34e8821599e7eff751d23c29c099f5abdc395a79
|
|
| MD5 |
4ace3d3ee39e91b49b550aec4652af30
|
|
| BLAKE2b-256 |
8aa28671be176baad1b87a5a42091d8b94d86969049bdb749175bac9f77378ba
|