Skip to main content

Bayesian version of STAPLE

Project description

Bayesian STAPLE

An algorithm to estimate the ground truth and performance parameter from a set of raters' segmentations.

Installation

pip install bayesian-staple

Example of usage

import numpy as np 
from bstaple import BayesianSTAPLE

rater1 = [0,0,0,1,1,1,0,0,0,0,0]
rater2 = [0,0,0,0,1,1,1,0,0,0,0]
rater3 = [0,0,0,0,1,1,1,0,0,0,0]
D = np.stack([rater1, rater2, rater3], axis=-1)

bayesianSTAPLE = BayesianSTAPLE(D)
trace = bayesianSTAPLE.sample(draws=10000, burn_in=1000, chains=3)

Extract the estimated ground truth:

soft_ground_truth = trace.T.mean(axis=(0,1)).values

Plot the raters' sensitivities and specifities:

import arviz as az
ax = az.plot_forest(
    trace,
    var_names=["p", "q"],
    hdi_prob=0.95,
    combined=True
  ) 

Arguments

  • D: array of {0,1} elements
    Raters' labels. This array must have this shape:
    ( dim_1, dim_2, ..., dim_N, raters).
    The first N dimensions refer to the data labeled by the raters.
    If repeated_labeling=True the shape must be:
    (dim_1, dim_2, ..., dim_N, iterations, raters).
  • w: 'hierarchical', [0,1] or array of [0,1] elements, default='hierarchical'
    If it is "hierarchical", this probability will be considered as a random variable and it will be estimated from the sampling.
    If it is a value between 0 and 1, all the items of the ground truth will have the same probability.
    If it is an array, each item of the ground truth will have the probability specified by the array. In this case, the w-array must have shape ( dim_1, dim_2, ..., dim_N).
  • repeated_labeling: boolean, default=False:
    Set to 'True' if the raters have made labeled multiple times for the same input. In this case, the data has to have shape (dim_1, dim_2, ..., dim_N, iterations, raters).
  • alpha_p: int, array of int, optional:
    Number of true positives.
  • beta_p: int, array of int, optional:
    Number of false positives.
  • alpha_q: int, array of int, optional:
    Number of true negatives.
  • beta_q: int, array of int, optional:
    Number of false negatives.
  • alpha_w: int, array of int, optional:
    Number of labels 1 that are expected to be in the ground truth.
  • beta_w: int, array of int, optional:
    Number of labels 0 that are expected to be in the ground truth.
  • seed: int, array of int, optional:
    Seed for the sampling algorithm.

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

bstaple-0.0.2.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

bstaple-0.0.2-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file bstaple-0.0.2.tar.gz.

File metadata

  • Download URL: bstaple-0.0.2.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Windows/11

File hashes

Hashes for bstaple-0.0.2.tar.gz
Algorithm Hash digest
SHA256 81cec1297e329f7be3b0403276ea3a807549e21b8e66f876449a556c8a9ddcc1
MD5 aee28cc1b7f9d571024eb63f72107cab
BLAKE2b-256 56a2b39bbd4f5f7be5960184d1b5b171c5dc3cf0e6cd6d2f7460deba5772bd5e

See more details on using hashes here.

File details

Details for the file bstaple-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: bstaple-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Windows/11

File hashes

Hashes for bstaple-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 55cfaa3b6bbae4e4a31c36334e49af1c8aafeeb7a61b798aada00277f4615a59
MD5 acf76db683c66cf89ca05a17b1902e82
BLAKE2b-256 a504ac459f1ea4c3daa7c26246498881cbe30af4a6cd1d57a9d8f08d1c9358fa

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