PPP#

class mlquantify.model_selection.PPP(batch_size, prevalences, repeats=1, random_state=None)[source]#

Personalized Prevalence Protocol (PPP).

Generates evaluation batches with explicitly specified class prevalences, enabling controlled evaluation at exact target operating points.

Parameters:
batch_sizeint or list of int

Batch sizes to generate.

prevalenceslist of float or array-like

Target class prevalences. A single float is interpreted as the positive class prevalence in binary problems (negative = 1 - float).

repeatsint, default=1

Number of repetitions per prevalence point.

random_stateint or None, default=None

Random seed for reproducibility.

Attributes:
n_combinationsint

Total number of batches generated.

Examples

>>> from mlquantify.model_selection import PPP
>>> import numpy as np
>>> X, y = np.random.randn(200, 5), np.random.randint(0, 2, 200)
>>> proto = PPP(batch_size=50, prevalences=[[0.2, 0.8], [0.5, 0.5]], random_state=0)
>>> batches = list(proto.split(X, y))
>>> len(batches)
2
get_metadata_routing()[source]#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating routing information.

get_n_combinations()[source]#

Get the number of combinations for the current protocol.

get_params(deep=True)[source]#

Get parameters for this estimator.

Parameters:
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
paramsdict

Parameter names mapped to their values.

save_quantifier(path: str | None = None) None[source]#

Save the quantifier instance to a file.

set_params(**params)[source]#

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:
**paramsdict

Estimator parameters.

Returns:
selfestimator instance

Estimator instance.

split(X: ndarray, y: ndarray)[source]#

Split the data into samples for evaluation.

Parameters:
Xnp.ndarray

The input features.

ynp.ndarray

The target labels.

Yields:
Generator[np.ndarray, np.ndarray]

A generator that yields the indices for each split.