Skip to main content

Partially Subsampled Multiple Instance Learning

This is a NumPy–based toolkit for multiple-instance learning (MIL) with Gaussian mixutre models. This is also a Python package accompanying the following paper:

Yu, B., Li, X., Zhou, J., and Wang, H. Detecting Breast Carcinoma Metastasis on Whole-Slide Images by Partially Subsampled Multiple Instance Learning, The Annals of Applied Statistics, To appear.

PSMIL implements:

  1. Instance-supervised MLE (InsMLE) when instance labels are available,
  2. Bag-only MLE (BagMLE) when only bag labels are available, and
  3. Subsampling MLE (SubMLE) that leverages subsampling to improve statistical efficiency.

For a tutorial and the CAMELYON16 analysis, see the GitHub repo:
https://github.com/Jamesyu420/PSMIL.

Installation

pip install PSMIL

Quick Start

All functions operate on NumPy arrays with shapes:

  • X: (N, M, p) float — features for N bags, M instances per bag, and p features
  • Y: (N,) int in {0,1} — bag labels
  • A: (N, M) int in {0,1} — instance labels

InsMLE

Instance-based MLE when A is observed.

ins = InsMLE(X, A, Y)

Returns a dict with keys:

  • 'mu1' (p,) — mean of positives,
  • 'mu0' (p,) — mean of negatives,
  • 'alpha' float — bag prevalence np.mean(Y),
  • 'pi' float — positive-instance rate on positive bags,
  • 'Sigma' (p,p) — pooled covariance.

BagMLE

BagMLE when only Y is used.

bag = BagMLE(
    X, Y,
    mu1_init, mu0_init, Sigma_init, pi_init,
    prt=False, iter=100, tol=1e-10
)

Parameters

  • mu1_init, mu0_init (p,): initial means
  • Sigma_init (p,p): initial covariance (SPD)
  • pi_init float in (0,1): initial positive-instance rate on positive bags
  • prt bool: print per-iter diagnostics
  • iter int: max iterations
  • tol float: stopping threshold on parameter change (squared L2 distance sum)

Returns a dict with:

  • 'mu1', 'mu0', 'Sigma', 'pi', 'alpha' — estimates
  • 'pi_im' (N,M) - Posterior probability
  • 'iter' int - iterations

SubMLE

SubMLE to subsample those instances that are likely to be positive.

alpha_n = sub_alphan(X, Y, est=bag, gamma_target=0.05)

sub = SubMLE(
    X, Y, A,
    mu1_init, mu0_init, Sigma_init, pi_init,
    est, alpha_n=alpha_n,
    prt=False, iter=100, tol=1e-10, seed=0
)

Here gamma_target is the target subsampling rate.

Contact

If you have any questions, please feel free to contact Baichen Yu and Prof. Xuetong Li.

Metadata

Release files for psmil 0.0.15

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

Source distribution (sdist)

Source distribution for psmil 0.0.15
File Size Uploaded Provenance Actions
psmil-0.0.15.tar.gz 6.0 kB Without provenance Details for psmil-0.0.15.tar.gz

Built distribution (wheel)

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

Total release size: 12.2 kB

Release files / psmil-0.0.15.tar.gz

Download URL psmil-0.0.15.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
881dd046c83f32ce9be0ec3475fc4e2c926839e59d2855f57b12f7d72e6f317b
BLAKE2b-256 checksum
How to use checksums
4cd4f685922e404a9fd8f4ef79a3ec79ef45f2d36551631ba16b64b6069718e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / psmil-0.0.15-py3-none-any.whl

Download URL psmil-0.0.15-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
25b9bcf5a58358e90f495d2be053b5441efd6586d80a1f209745bbcb9046228b
BLAKE2b-256 checksum
How to use checksums
9d74ed46d2f4dd0f22b0d0b08bcaedd21151ca8a5061e47f357557ff2d9ab937
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Security for psmil 0.0.15

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.0.15 This release

2 release files No provenance

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