Skip to main content

PyPlasmode

PyPlasmode tests prediction and feature selection against a known signal. It combines your feature data with simulated outcomes, so you can measure both how accurately a model predicts and how well it identifies the features used to generate those outcomes.

Built for biomarker benchmarking, the library works with numeric tabular data more generally. Its inputs are a matrix of observations and named features, not a particular assay or dataset. A plasmode uses observed measurements to retain realistic feature relationships while you control the outcome-generating mechanism. Synthetic matrices work too, as in the examples below.

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 feature-selection tutorial follows a complete example from correlated measurements through model fitting, attribution and recovery above chance.

Installation

Requires Python 3.12-3.15. Install PyPlasmode 1.2.0 from PyPI:

python -m pip install pyplasmode

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

python -m pip install "pyplasmode[validation]"

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"feature_{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=("feature_3", "feature_17", "feature_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 observations. Repeat the comparison with different seeds to estimate average performance and its Monte Carlo uncertainty. In 1.2.0, compare_paired_replicates aligns procedures by world identity before computing paired effects and explicitly counts failed or unmatched pairs. See paired evaluation.

Source rows 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.

New in 1.2.0

Version 1.2.0 extends generation and evaluation. pyplasmode.metrics adds chance-corrected selection stability, tie-aware RBO, consensus ranks, censored cumulative/dynamic AUROC, paired participant bootstrap differences and discrimination gaps. Binary and survival specifications accept target_auc and report the solved effect and expected oracle AUROC. See metrics, calibration and the worked example.

The synthetic benchmark fits Cox, ridge and XGBoost across three signal mechanisms and three target oracle AUROCs, then compares held-out AUROC with chance-adjusted top-20 recovery. Install the optional benchmark extra to run python examples/benchmark_recovery_demo.py. Install it with python -m pip install "pyplasmode[benchmark]".

Metadata

Release files for pyplasmode 1.2.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.2.0
File Size Uploaded Provenance Actions
pyplasmode-1.2.0.tar.gz 2.1 MB With provenance Details for pyplasmode-1.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 2.2 MB

Release files / pyplasmode-1.2.0.tar.gz

Download URL pyplasmode-1.2.0.tar.gz
Size 2.1 MB
Tags Source
SHA-256 checksum
How to use checksums
289de6621a707589147088b9d4696f5e21dd066ecfc696ddd4773d05a0686fdf
BLAKE2b-256 checksum
How to use checksums
c9507ecca0e43412bb04e5939c26f06c3a77d642df7377ec93388daab61b3c57
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 Nov 9, 2026.

Transparency log

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

Download URL pyplasmode-1.2.0-py3-none-any.whl
Size 46.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1cabbedf9c34beab4a63cdc251238ce9310bcda92307f4a10c1509af056dffad
BLAKE2b-256 checksum
How to use checksums
9e8f5d39ebecc8d0161bbae8fcaa7efc4c26168681cb7d4ceb937a7d1cdd79f1
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 Nov 9, 2026.

Transparency log

Security for pyplasmode 1.2.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyplasmode-1.2.0.tar.gz

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 Nov 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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