mlquantify.utils#

get_prev_from_labels

Get the real prevalence of each class in the target array.

load_quantifier

Load a quantifier from a file.

make_prevs

Generate a list of n_dim values uniformly distributed between 0 and 1 that sum exactly to 1.

apply_cross_validation

Perform cross-validation and return predictions with true labels for each fold.

simplex_uniform_kraemer

Generates n_prev prevalence vectors of n_dim classes uniformly distributed on the simplex, with optional lower and upper bounds.

simplex_grid_sampling

Efficiently generates artificial prevalence vectors that sum to 1 and respect min_val ≤ p_i ≤ max_val for all i.

simplex_uniform_sampling

Generates uniformly distributed prevalence vectors within the simplex, constrained by min_val ≤ p_i ≤ max_val.

get_indexes_with_prevalence

Get indexes for a stratified sample based on the prevalence of each class.