Skip to main content

PyPlasmode

PyPlasmode benchmarks the reliability of biomarker discovery. A model can predict disease accurately while selecting proteins that only track the underlying signal. To evaluate its explanations, you need a comparison in which the relevant features are known. PyPlasmode creates that comparison by generating outcomes from specified effects within your measurements.

Use it with your existing modelling workflow: generate a dataset, fit and tune your models, then evaluate their predictions, feature rankings or selected panels.

From observed measurements to simulated outcomes, model predictions and feature recovery

The same generated dataset supports two comparisons: predictions against outcomes, and selected features against the signal that generated them.

Explore the visual gallery for signal patterns, correlated-feature recovery and the five outcome families.

The biomarker tutorial follows a complete example from correlated measurements through model fitting, attribution and recovery above chance.

Installation

Requires Python 3.12-3.14. Install from GitHub:

python -m pip install "git+https://github.com/BradSegal/PyPlasmode.git@v1.0.0"

The runtime dependencies are NumPy, SciPy and scikit-learn. To include the reference validation and survival examples, install the validation extra:

python -m pip install "PyPlasmode[validation] @ git+https://github.com/BradSegal/PyPlasmode.git@v1.0.0"

Ten-minute example

import numpy as np
from sklearn.linear_model import LogisticRegression
import pyplasmode as ppm

rng = np.random.default_rng(1)
population = ppm.Population(
    rng.normal(size=(2_000, 100)),
    tuple(f"protein_{index}" for index in range(100)),
)

partition = ppm.partition_population(
    population,
    training_fraction=0.6,
    validation_fraction=0.2,
    seed=7,
)
samples = ppm.generate_partitioned(
    partition,
    truth=ppm.SparseTruth(features=("protein_3", "protein_17", "protein_42")),
    outcome=ppm.BinaryOutcome(probability=0.15, odds_ratio=2.0),
    sample_sizes=ppm.PartitionSampleSizes(1_200, 400, 400),
    sampling_method="without_replacement",
    seed=42,
)

train, test = samples.training, samples.evaluation
model = LogisticRegression(max_iter=1_000).fit(train.X, train.outcome.values)
ranking = tuple(train.feature_ids[index] for index in np.argsort(-np.abs(model.coef_[0])))

recovery = ppm.evaluate_ranking(ranking, train.truth, depths=(10, 20, 50))
prediction = ppm.evaluate_prediction(
    test.outcome.values,
    model.predict_proba(test.X)[:, 1],
    metric="roc_auc",
)
print(recovery.at_depth[0].recall)
print(prediction.value)

Recall measures how many of the three generating features appear in the model's top ten; AUC measures prediction on held-out participants. Repeat the comparison with different seeds to estimate average performance and its Monte Carlo uncertainty.

Source participants are split before resampling, keeping training, validation and test rows separate. This example uses a fixed model; the validation sample is available for hyperparameter tuning. See Methods for the generation process.

What can be varied

  • Signal: null, sparse features, correlated groups, distributed modules, pairwise interactions or a custom function.
  • Outcome: binary probability, continuous mean and spread, count rate, ordinal category probabilities or cumulative event risks at native-time horizons.
  • Evaluation: feature and group recovery, weighted-module and graph-region coverage, signal reconstruction, prediction accuracy, panel performance and ranking stability. Additional functions handle tied scores, incomplete selections and matched chance references.

Start with Methods, then choose a signal and outcome. The evaluation guide defines each result. The validation example checks the generators and recovery metrics against known values and reference estimators.

The executable quickstart, survival example and custom signal use synthetic inputs. The documentation includes the generation methods, evaluation definitions and API reference.

Working with empirical data

Resampling preserves the source data's feature relationships and missingness patterns. It can reproduce individual records, so generated datasets require the same privacy protections as their source. See Data handling.

Licence

PyPlasmode uses the BSD 3-Clause License.

Metadata

Release files for pyplasmode 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyplasmode 1.0.0
File Size Uploaded
pyplasmode-1.0.0.tar.gz 12.2 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyplasmode 1.0.0
File Interpreter ABI Platform
pyplasmode-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.2 MB

Release files / pyplasmode-1.0.0.tar.gz

Download URL pyplasmode-1.0.0.tar.gz
Size 12.2 MB
Tags Source
SHA-256 checksum
How to use checksums
28e8b8ac74ab73e88dc805a4c82502a99ce358cdc9683f5cec9e5202193d3c5d
BLAKE2b-256 checksum
How to use checksums
73cc021e51d92f29ac76b54502ac1c386c1a922e2f39c68e4a270234b62faa6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.

Transparency log

Release files / pyplasmode-1.0.0-py3-none-any.whl

Download URL pyplasmode-1.0.0-py3-none-any.whl
Size 36.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60dc7f47ee64d705e61efffc84a71d5ef7ada4120f348b849c6b8ca9718a186a
BLAKE2b-256 checksum
How to use checksums
d8ac92153c96c358b637a46e13f6f12ef7393b07bb4fefc5110d5535dc06f132
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page