Skip to main content

OCCAM Reconstructability Analysis Tools

Project description

PyOccam

Python bindings for OCCAM Reconstructability Analysis

Build Wheels

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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyoccam-0.9.5.tar.gz (1.1 MB view details)

Uploaded Source

Built Distributions

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

pyoccam-0.9.5-cp312-cp312-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.12Windows x86-64

pyoccam-0.9.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyoccam-0.9.5-cp312-cp312-macosx_10_9_universal2.whl (1.5 MB view details)

Uploaded CPython 3.12macOS 10.9+ universal2 (ARM64, x86-64)

pyoccam-0.9.5-cp311-cp311-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.11Windows x86-64

pyoccam-0.9.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyoccam-0.9.5-cp311-cp311-macosx_10_9_universal2.whl (1.5 MB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

pyoccam-0.9.5-cp310-cp310-win_amd64.whl (1.5 MB view details)

Uploaded CPython 3.10Windows x86-64

pyoccam-0.9.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pyoccam-0.9.5-cp310-cp310-macosx_10_9_universal2.whl (1.5 MB view details)

Uploaded CPython 3.10macOS 10.9+ universal2 (ARM64, x86-64)

pyoccam-0.9.5-cp39-cp39-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.9Windows x86-64

pyoccam-0.9.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pyoccam-0.9.5-cp39-cp39-macosx_10_9_universal2.whl (1.5 MB view details)

Uploaded CPython 3.9macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file pyoccam-0.9.5.tar.gz.

File metadata

  • Download URL: pyoccam-0.9.5.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

Hashes for pyoccam-0.9.5.tar.gz
Algorithm Hash digest
SHA256 b33e16df5e0423b78e1490f8966fecb55dffc917e5b24f779ebcf81e8febc0a8
MD5 1fa428e2e733fdde56e45dfa43701cf3
BLAKE2b-256 b36ddda0e8c74a77e02bafe18876d69f362b75c8b05f514446cfdd43a0e6f70d

See more details on using hashes here.

File details

Details for the file pyoccam-0.9.5-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pyoccam-0.9.5-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

Hashes for pyoccam-0.9.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7026a58f2df444c2902915e8a0452e5f4f1a22c512c53ae9c69d0c8407403547
MD5 5f142698ade052c4fcbcfaaf6677e0ca
BLAKE2b-256 bf1eb3fdb77197c3a434d53900d5c5bffab5f3244850110bd56c6afbd89067be

See more details on using hashes here.

File details

Details for the file pyoccam-0.9.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyoccam-0.9.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 34858f84c40795a4ad0e97cdd93195c326c4ce0298f76bb2beb1172b9156daa6
MD5 391a592e7fc1fe0504f3e3d9b61ef2e1
BLAKE2b-256 9b9bcfb2ce306032d4500dc53d68c07dc51451adca32bca5baa0f9005d9931e6

See more details on using hashes here.

File details

Details for the file pyoccam-0.9.5-cp312-cp312-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pyoccam-0.9.5-cp312-cp312-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 c2b06f23e1be5e962a7186fc88669c34e8dd6c62154d6bd804c338785fa74f09
MD5 6322bc721661d3556a85a781fac20a3f
BLAKE2b-256 3fdcf346136ac60b5441719362c8032b64849e8ca0bebf0b9a622cee6ff71ff6

See more details on using hashes here.

File details

Details for the file pyoccam-0.9.5-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyoccam-0.9.5-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

Hashes for pyoccam-0.9.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 dac4d60edc687d3ef1fea0f1a6753d289136baaf9b14eb714de55fda6e55ba1c
MD5 48d8044a1d99eff74a9a4e2586d115d1
BLAKE2b-256 282d41487d0348be92859164e42c508b0991b329f381a5d671881e362cffb89a

See more details on using hashes here.

File details

Details for the file pyoccam-0.9.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyoccam-0.9.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 463f0655aa91db828b56695863744a2be46e3f49b9d0f714c3f251d8040c1f0e
MD5 4f4a0c1f1573925db43e63928b51fbb3
BLAKE2b-256 b496278a06192d727ac4b17a505e24f873ac35b313d2abc725e746dabb122402

See more details on using hashes here.

File details

Details for the file pyoccam-0.9.5-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pyoccam-0.9.5-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 a25ec058985c68a8ccd20d4008a0f789d64b247ec854e0ad01710cbe7b9c87d9
MD5 a6d6b747a621deb0a67ec4bcc0cea512
BLAKE2b-256 633509d02de3b2cae244b802ed89f2580254c3c84e48fa23d752f682f16e26b2

See more details on using hashes here.

File details

Details for the file pyoccam-0.9.5-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pyoccam-0.9.5-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

Hashes for pyoccam-0.9.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 eaec47bf01814582eda06f30d349e2aeba9081886a80e6c1639651bcd48d8820
MD5 b624e63f48ec2c767bf39813d698dc69
BLAKE2b-256 d9c540af92cbf1cd7faa92b4bd892f10f07dc685937a2e4d2550375f889f7072

See more details on using hashes here.

File details

Details for the file pyoccam-0.9.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyoccam-0.9.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0f9b5e0a67ca56bfbfb0e8448b2c35813e9b6b64b50f335ab6e29f11a45ea8f7
MD5 59925df715b99f70d6c5ec9594b6b425
BLAKE2b-256 0b74123306155c72c9ac4473a97a513e9610a6f8acbacfad52abb853d3d090d4

See more details on using hashes here.

File details

Details for the file pyoccam-0.9.5-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pyoccam-0.9.5-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 a5b70e88eb349596986efe089e6e115ee6be1d630571dd8fa8f048dfaf506682
MD5 2b9addc747bdd56470fc45d2be7ea62c
BLAKE2b-256 f31803ebb8ff75d3f4a68399054038757041c065bcc63d4b27e61ff47abf1d38

See more details on using hashes here.

File details

Details for the file pyoccam-0.9.5-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pyoccam-0.9.5-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

Hashes for pyoccam-0.9.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 64118b4c6410b6cf8b26dd182ed3cee4553e9f232d7443cd72567add804a9a79
MD5 891a5f615bb1d91a4c4def1212e5ce2f
BLAKE2b-256 d1de82ffdf307a29a0f1fbf4614ba7713881d80159ea8a6e9cc1dab234119be7

See more details on using hashes here.

File details

Details for the file pyoccam-0.9.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyoccam-0.9.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7fa5c900192bfb55c3894aeab76eb8173c37961b04cc692740148357ff5f13a6
MD5 86b0e21283ba850938d73ecaa54ba59d
BLAKE2b-256 8cf1cc2ac31b5356bcc96eed6637594be43e3c85dbe73990721094c0d83f6ca1

See more details on using hashes here.

File details

Details for the file pyoccam-0.9.5-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pyoccam-0.9.5-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 8e2b4afe8ad66d73922e59ffbb7c0396237854b10defb6e047c1ddd8d4fcd2c0
MD5 11e901d8ae0951a168665f3dc175fe46
BLAKE2b-256 9015ed8e6c43431b3342296af431d64c3d7ff64b1683365ea541a349adbc3805

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