API Reference#
This is the class and function reference of mlquantify. Please refer to the full user guide for further details, as the raw specifications of classes and functions may not be enough to give full guidelines on their use. For reference on core concepts, see the Foundations guide.
Object |
Description |
|---|---|
Retrieve the current mlquantify configuration. |
|
Set global mlquantify configuration. |
|
Context manager to temporarily change the global mlquantify configuration. |
|
Base class for all quantifiers in mlquantify. |
|
Mixin class for meta-quantifiers. |
|
Mixin class for protocol-based quantifiers. |
|
Mixin class for all aggregative quantifiers. |
|
Soft predictions mixin for aggregative quantifiers. |
|
Crisp predictions mixin for aggregative quantifiers. |
|
Base class for calibrators. |
|
Post-hoc calibration of classifier posteriors by logit scaling. |
|
Post-hoc calibration of quantifier prevalence estimates. |
|
Base class for compose-based quantifiers. |
|
Compose quantifier for linear representation matching. |
|
Compose quantifier based on mixture negative log-likelihood. |
|
Compose quantifier for linear representation matching. |
|
Base class for confidence regions of prevalence estimates. |
|
Bootstrap confidence intervals for each class prevalence. |
|
Confidence ellipse for prevalence estimates in the simplex. |
|
Confidence ellipse for prevalence estimates in CLR-transformed space. |
|
Instantiate a confidence region from bootstrap prevalence estimates. |
|
Classify and Count (CC) quantifier. |
|
Probabilistic Classify and Count (PCC) quantifier. |
|
Adjusted Classify and Count (ACC) quantifier. |
|
Abstract base class for ROC-threshold adjustment quantifiers. |
|
Threshold Adjusted Count (TAC) quantifier. |
|
Threshold X (TX) quantifier. |
|
Threshold MAX (TMAX) quantifier. |
|
Threshold 50 (T50) quantifier. |
|
Median Sweep (MS) quantifier. |
|
Median Sweep 2 (MS2) quantifier. |
|
Friedman Method (FM) quantifier. |
|
Generalized Adjusted Classify and Count (GACC). |
|
Generalized Probabilistic Adjusted Classify and Count (GPACC). |
|
Evaluate a range of classification thresholds to compute the corresponding True Positive Rate (TPR) and False Positive Rate (FPR) for a binary quantification task. |
|
Compute the True Positive Rate (Recall) for a binary classification task. |
|
Compute the False Positive Rate for a binary classification task. |
|
Compute the confusion matrix table for a binary classification task. |
|
Generate synthetic quantification bags under prior-probability shift. |
|
Mushroom: edible vs. poisonous (binary, all-categorical). |
|
Banknote authentication from wavelet image features (binary). |
|
Haberman survival after breast-cancer surgery (binary, hard). |
|
MiniBooNE particle identification: signal vs. background (binary, large). |
|
Optical / Pen-based handwritten digits (10-class, easy). |
|
Dry Bean: seven bean varieties from grain morphology (multiclass). |
|
Forest Covertype: 7 cover types from cartographic variables (multiclass, large). |
|
Yeast protein localization site (10-class, hard, imbalanced). |
|
Sensorless drive diagnosis from motor current signals (11-class, balanced). |
|
Statlog (Shuttle): space-shuttle radiator states (multiclass, extreme imbalance). |
|
Wine Quality: sensory score 3-9 from physicochemistry (ORDINAL). |
|
Online News Popularity: will an article be popular? (binary, temporal). |
|
Pima Indians Diabetes (binary, hard, noisy medical). |
|
Electricity (Elec2): NSW market price up/down stream (binary, drift). |
|
Airlines: flight-delay stream (binary, large, temporal). |
|
20 Newsgroups: Usenet posts in 20 topics (text, multiclass). |
|
IMDB Large Movie Review sentiment (text, binary, balanced). |
|
Multi-Domain (Blitzer) Amazon review sentiment (text, covariate shift). |
|
Sentiment140: 1.6M timestamped tweets (text, binary, temporal). |
|
RCV1-v2: Reuters news topics (text, sparse TF-IDF, multilabel). |
|
MNIST -> USPS handwritten digits (image, covariate shift). |
|
CIFAR-10 natural images (image, 10-class, balanced). |
|
Planetoid citation graphs: Cora / CiteSeer / PubMed (graph nodes). |
|
SEA Concepts: synthetic stream with abrupt concept drift (binary). |
|
LeQua 2024 competition vectors, all tasks via |
|
urllib download with local cache + retries (like sklearn). Retries once unverified on TLS errors. |
|
CDE-Iterate quantifier. |
|
Expectation-Maximization Quantifier (EMQ / SLD). |
|
Maximum Likelihood Prevalence Estimation (MLPE) quantifier. |
|
Base class for optimization losses. |
|
Generic distance-based loss between two probability distributions. |
|
Squared Euclidean (least-squares) loss. |
|
Optimization surrogate for the squared Hellinger distance. |
|
Energy-distance loss for distribution matching. |
|
Negative log-likelihood loss for mixture likelihoods. |
|
Negative log-likelihood for class likelihood mixtures. |
|
Mixture NLL with optional ordinal-smoothness regularization. |
|
Normalize an array to a valid probability distribution. |
|
Instantiate a loss object from a string identifier or return a callable. |
|
Base class for distribution matching quantifiers. |
|
Abstract base class for histogram-based distribution matching. |
|
Distribution y-Similarity (DyS) quantifier. |
|
Hellinger Distance y (HDy) quantifier. |
|
Hellinger Distance x (HDx) quantifier. |
|
Sample Ordinal Distance (SORD) quantifier. |
|
Abstract base class for kernel mean matching quantifiers. |
|
Maximum Mean Discrepancy in RKHS (MMD-RKHS) quantifier. |
|
Abstract base class for KDE-based density matching quantifiers. |
|
KDEy Maximum Likelihood (KDEy-ML) quantifier. |
|
KDEy Hellinger Distance (KDEy-HD) quantifier. |
|
KDEy Cauchy-Schwarz (KDEy-CS) quantifier. |
|
Generalized KDEy Maximum Likelihood (GKDEyML) quantifier. |
|
Generalized HDx (GHDx) quantifier. |
|
Generalized HDy (GHDy) quantifier. |
|
Sample Mean Matching (SMM) quantifier. |
|
Energy Distance y (EDy) quantifier. |
|
Energy Distance x (EDx) quantifier. |
|
Ensemble Quantifier with prevalence-controlled diversity. |
|
QuaDapt: drift-resilient quantification via parameter adaptation. |
|
Aggregative Bootstrap quantifier for prevalence confidence regions. |
|
Compute the absolute error for each class or a dictionary of errors if input is a dictionary. |
|
Compute the mean squared error between the real and predicted prevalences. |
|
Compute the mean absolute error between the real and predicted prevalences. |
|
Mean Squared Error |
|
Compute the Kullback-Leibler divergence between the real and predicted prevalences. |
|
Compute the relative absolute error between the real and predicted prevalences. |
|
Compute the normalized absolute error between the real and predicted prevalences. |
|
Compute the normalized relative absolute error between the real and predicted prevalences. |
|
Compute the normalized Kullback-Leibler divergence between the real and predicted prevalences. |
|
Compute the Normalized Match Distance (NMD), also known as Earth Mover’s Distance (EMD), for ordinal quantification evaluation. |
|
Compute the Root Normalised Order-aware Divergence (RNOD) for ordinal quantification evaluation. |
|
Compute the Variance-normalised Squared Error (VSE). |
|
Compute the L1 version of the Cramér–von Mises statistic (Xiao et al., 2006) between two cumulative distributions, as suggested by Bella et al. (2014). |
|
Grid search over quantifier hyperparameters with evaluation protocols. |
|
Abstract base class for evaluation protocols. |
|
Artificial Prevalence Protocol (APP). |
|
Natural Prevalence Protocol (NPP). |
|
Uniform Prevalence Protocol (UPP). |
|
Personalized Prevalence Protocol (PPP). |
|
Evaluate a quantifier across an evaluation protocol. |
|
Decorator to enable binary quantification extensions (One-vs-Rest or One-vs-One). |
|
Meta-quantifier enabling One-vs-Rest and One-vs-One strategies. |
|
Base class for multiclass decomposition strategies. |
|
Register a |
|
Return the registered |
|
Return the sorted names of all registered multiclass strategies. |
|
Probabilistic Weighted k-Nearest Neighbour (PWK) quantifier. |
|
QuaNet: deep neural quantification with an LSTM architecture. |
|
Base class for quantification representations. |
|
Histogram-based representation. |
|
Kernel density estimation representation. |
|
Distance-based representation for quantification. |
|
Kernel mean embedding representation. |
|
Representation based on classifier predictions. |
|
Hard-prediction representation convenience class. |
|
Soft-prediction representation convenience class. |
|
Minimize a scalar objective over the binary prevalence space [0, 1]. |
|
Find the minimum of a unimodal function via ternary search. |
|
Minimize a function over the probability simplex using SLSQP. |
|
Minimize an objective function over the probability simplex. |
|
Minimize a loss over multiple representation blocks and aggregate results. |
|
Get the real prevalence of each class in the target array. |
|
Normalize the prevalence of each class to sum to 1. |
|
Load a quantifier from a file. |
|
Generate a list of n_dim values uniformly distributed between 0 and 1 that sum exactly to 1. |
|
Perform cross-validation and return predictions with true labels for each fold. |
|
Generates n_prev prevalence vectors of n_dim classes uniformly distributed on the simplex, with optional lower and upper bounds. |
|
Efficiently generates artificial prevalence vectors that sum to 1 and respect min_val ≤ p_i ≤ max_val for all i. |
|
Generates uniformly distributed prevalence vectors within the simplex, constrained by min_val ≤ p_i ≤ max_val. |
|
Get indexes for a stratified sample based on the prevalence of each class. |
|
True vs. predicted prevalence diagonal plot. |
|
Boxplots of signed prevalence-estimation error. |
|
Estimation error as a function of prior-probability shift. |
|
Bar chart of a single sample’s predicted class prevalence. |
|
Confidence region around a single prevalence prediction. |