BaseProtocol#
- class mlquantify.model_selection.BaseProtocol(batch_size, random_state=None, **kwargs)[source]#
Abstract base class for evaluation protocols.
Provides the
splitinterface that yields sample indices for evaluating a quantifier across varying prevalence conditions. Subclasses implement_iter_indicesto define the specific sampling strategy.- Parameters:
- batch_sizeint or list of int
Size(s) of the evaluation batches.
- random_stateint or None, default=None
Random seed for reproducibility.
- Attributes:
- n_combinationsint
Total number of batches this protocol will generate.
Examples
>>> from mlquantify.model_selection._protocol import BaseProtocol >>> import numpy as np >>> class MyProtocol(BaseProtocol): ... def _iter_indices(self, X, y): ... rng = np.random.default_rng(self.random_state) ... for bs in self.batch_size: ... yield rng.choice(len(X), bs, replace=True) >>> X, y = np.random.randn(200, 5), np.random.randint(0, 2, 200) >>> proto = MyProtocol(batch_size=50, random_state=0) >>> idx = next(proto.split(X, y)) >>> len(idx) 50
- get_metadata_routing()[source]#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequestencapsulating routing information.
- 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.
- 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.