BaseProtocol#
- class mlquantify.model_selection.BaseProtocol(batch_size, random_state=None, **kwargs)[source]#
Base class for evaluation protocols.
- Parameters:
- batch_sizeint or list of int
The size of the batches to be used in the evaluation.
- random_stateint, optional
The random seed for reproducibility.
- Attributes:
- n_combinationsint
- Raises:
- ValueError
If the batch size is not a positive integer or list of positive integers.
Notes
This class serves as a base class for different evaluation protocols, each with its own strategy for splitting the data into batches.
Examples
>>> class MyCustomProtocol(Protocol): ... def _iter_indices(self, X: np.ndarray, y: np.ndarray): ... for batch_size in self.batch_size: ... yield np.random.choice(X.shape[0], batch_size, replace=True) ... >>> protocol = MyCustomProtocol(batch_size=100, random_state=42) >>> for idx in protocol.split(X, y): ... # Train and evaluate model ... pass
- 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.