Skip to main content

ML-Enhanced Pharmacometrics Toolkit

Project description

pharmacoml

ML-Enhanced Pharmacometrics Toolkit for Python

pharmacoml brings machine learning methods to pharmacometrics workflows — usable with or without NONMEM.

Why pharmacoml?

Existing ML tools for pharmacometrics (pyDarwin, shap-cov) require a NONMEM license. pharmacoml is estimation-tool agnostic — it works with empirical Bayes estimates from NONMEM, nlmixr2, Monolix, Pumas, or manual estimation.

Quick Start

The recommended default workflow is the hybrid preselection path: explainable boosting with benchmark-approved recursive elimination for discovery, augmented adaptive LASSO for confirmation, optional stochastic-gates and symbolic-structure confirmation, and tiered output for downstream SCM/backward elimination.

from pharmacoml.covselect import HybridScreener
import pandas as pd

ebes = pd.read_csv("individual_parameters.csv")
covs = pd.read_csv("covariates.csv")

report = HybridScreener(include_scm=True).fit(ebes, covs)

report.confirmed_covariates()  # recommended daily-use answer
report.core_covariates()       # strongest ML signals
report.candidate_covariates()  # broader shortlist for exploration
report.scm_covariates()        # explicit SCM-confirmed set
report.proxy_groups()
print(report.to_nonmem_candidates())

Experimental Consensus

For broader research comparisons, the experimental namespace exposes a curated multi-model consensus workflow. It runs a scikit-first model set by default, aggregates top-k covariate frequency across model families, and lets you compare that consensus against the main hybrid workflow.

from pharmacoml.covselect.experimental import MultiModelConsensusScreener

report = MultiModelConsensusScreener(
    top_k=3,
    n_bootstrap=8,
    include_neural=False,
).fit(ebes, covs)

report.consensus_covariates()
report.selection_frequency_table()

Benchmark-Gated Development

pharmacoml now carries a release benchmark suite for default-calibration work:

  • pheno (Pharmpy phenobarbital example)
  • Eleveld/Wahlquist public propofol data
  • ggPMX Monolix theophylline example
  • Asiimwe-style correlated-covariate simulation
  • Shap-Cov-style collinear simulation
  • optional Kekic public synthetic scenarios when the repo is available locally

The benchmark harness compares the default hybrid workflow against optional variants such as RFE and shrinkage-awareness. The current benchmark-approved defaults are rfe_enabled=True and shrinkage_awareness=True.

PYTHONPATH=. python benchmarks/run_public_benchmarks.py --check

By default, that command now writes a reusable report bundle to benchmarks/reports/fixed_public/:

  • public_benchmark_report.md
  • public_benchmark_summary.csv
  • public_benchmark_details.csv
  • public_benchmark_report.json

Use --no-report to skip artifact generation, or --report-dir <path> to write the bundle somewhere else.

Optional Advanced Backends

pharmacoml now includes:

  • a nonlinear stochastic-gates engine (STG) with an input-gated MLP body
  • symbolic covariate structure search with three backends:
    • basis (default, lightweight pharmacometric basis search)
    • gplearn (optional true symbolic regression)
    • pysr (optional true symbolic regression; install manually)

Example:

report = HybridScreener(
    include_symbolic=True,
    symbolic_backend="basis",
    include_stg=True,
).fit(ebes, covs)

Install optional extras:

pip install -e ".[dev,dl,symbolic]"

Installation

git clone https://github.com/s-rani1/pharmacoml.git
cd pharmacoml
pip install -e ".[dev]"

Modules

Module Description Status
pharmacoml.covselect Hybrid ML-assisted covariate screening with SCM bridge 🚧 Active
pharmacoml.expose Exposure-response with interpretable ML 📋 Planned
pharmacoml.trajpk PK/PD trajectory clustering 📋 Planned

License

MIT

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

pharmacoml-0.1.0.tar.gz (71.4 kB view details)

Uploaded Source

Built Distribution

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

pharmacoml-0.1.0-py3-none-any.whl (80.3 kB view details)

Uploaded Python 3

File details

Details for the file pharmacoml-0.1.0.tar.gz.

File metadata

  • Download URL: pharmacoml-0.1.0.tar.gz
  • Upload date:
  • Size: 71.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for pharmacoml-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a5c387337f3ca6181ed41227c5bb6dcd9687c1d0204a7f22fb1598cf0f878243
MD5 5342a6f4ed82e9075b72d2760c728cfd
BLAKE2b-256 01bb52ad01cbae3af831b9dd557b3f862ff9db6df5c1d6f96b4bece9333793e8

See more details on using hashes here.

File details

Details for the file pharmacoml-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pharmacoml-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 80.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for pharmacoml-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b6640db9281d34e9c6472159f3660271c8e712eb064899c127102e6abe059926
MD5 a1263102e829d54482812c3713123d63
BLAKE2b-256 8a2bbfa38de88738f7c0fdd94d7befac3c56e5c2411a2e794a815b9d8938578f

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