Skip to main content

psmil package

Project description

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.

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

psmil-0.0.15.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

psmil-0.0.15-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file psmil-0.0.15.tar.gz.

File metadata

  • Download URL: psmil-0.0.15.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for psmil-0.0.15.tar.gz
Algorithm Hash digest
SHA256 881dd046c83f32ce9be0ec3475fc4e2c926839e59d2855f57b12f7d72e6f317b
MD5 e9ab27873f1d3df8587415c8355847a9
BLAKE2b-256 4cd4f685922e404a9fd8f4ef79a3ec79ef45f2d36551631ba16b64b6069718e6

See more details on using hashes here.

File details

Details for the file psmil-0.0.15-py3-none-any.whl.

File metadata

  • Download URL: psmil-0.0.15-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for psmil-0.0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 25b9bcf5a58358e90f495d2be053b5441efd6586d80a1f209745bbcb9046228b
MD5 56c8dbbd12dde88ce142ad32f9beddc5
BLAKE2b-256 9d74ed46d2f4dd0f22b0d0b08bcaedd21151ca8a5061e47f357557ff2d9ab937

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