Skip to main content

A python project for interpreting molecular dynamics trajectory metastable state classifications from machine-learning models

Project description

MDTerp

image

MDTerp

MDTerp interprets black-box AI classifiers trained on molecular dynamics (MD) trajectory data. It identifies which molecular features drive transitions between metastable states by building local, interpretable surrogate models around transition-state samples.

MDTerp implements the TERP (Thermodynamics-inspired Explanations using Ridge regression with Perturbation) framework, which uses concepts from statistical mechanics — unfaithfulness as energy, interpretation entropy, and interpretation free energy — to automatically determine the optimal number of features needed to explain each transition.

Key Features

  • Adaptive transition detection: Automatically tunes probability thresholds per transition to select the most informative samples
  • Multi-CPU parallel analysis: Analyze multiple transition-state points simultaneously across available CPU cores
  • Crash recovery: Resume interrupted analyses from per-point checkpoints
  • Forward feature selection: Thermodynamics-inspired approach to determine optimal feature count
  • Built-in visualizations: Feature importance bar plots, cross-transition heatmaps, unfaithfulness curves, and per-point variability plots

Installation

pip install MDTerp

Quick Start

import MDTerp

# Run MDTerp analysis
result = MDTerp.run(
    np_data=training_data,
    model_function_loc='path/to/model_script.txt',
    numeric_dict={'feature_1': [0], 'feature_2': [1]},
    save_dir='./results/',
    point_max=50,               # Target points per transition
    prob_threshold_min=0.475,   # Minimum threshold floor
    n_workers=4,                # Parallel CPU workers
)

# Visualize results
MDTerp.plot_feature_importance(
    'results/MDTerp_results_all.pkl',
    'results/MDTerp_feature_names.npy',
    transition='0_1',
)

Parameters

Parameter Default Description
point_max 50 Target number of points per transition
prob_threshold_min 0.475 Minimum probability threshold (floor)
n_workers CPU count Number of parallel worker processes
num_samples 10000 Perturbed neighborhood size
cutoff 15 Max features kept after initial round
keep_checkpoints True Keep per-point result files for crash recovery

Demos

Citation

If you use MDTerp, please cite:

@article{mehdi2024thermodynamics,
  title={Thermodynamics-inspired explanations of artificial intelligence},
  author={Mehdi, Shams and Tiwary, Pratyush},
  journal={Nature Communications},
  volume={15},
  pages={3974},
  year={2024},
  publisher={Nature Publishing Group},
  doi={10.1038/s41467-024-47258-w}
}

Mehdi, S., Tiwary, P. Thermodynamics-inspired explanations of artificial intelligence. Nat Commun 15, 3974 (2024). https://doi.org/10.1038/s41467-024-47258-w

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

mdterp-5.0.1.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

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

mdterp-5.0.1-py2.py3-none-any.whl (25.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file mdterp-5.0.1.tar.gz.

File metadata

  • Download URL: mdterp-5.0.1.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for mdterp-5.0.1.tar.gz
Algorithm Hash digest
SHA256 487fc04583ba9eb650414ceeb48731dab8ef8df0ded08ca6fbe41f26512cbe5b
MD5 4c298dcbd551a42e1a2a308a8dadb2e2
BLAKE2b-256 386e0ec22315b3b5bd805b3611ccfbbaf02876f9114f4c3d6f889d825bae68bf

See more details on using hashes here.

File details

Details for the file mdterp-5.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: mdterp-5.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 25.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for mdterp-5.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 596cc8e27c20c37f26e3497d9f77f21d19bbfb396cbc7199ae1d9a0d8908e58b
MD5 a75ab586ee641b6c630915f6b26ca4e2
BLAKE2b-256 5377a18b8277ac269c1a9814c496920e48d1394acbe611ce7e5495eb80936de3

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