sampleable¶
- class SampleableMixin¶
Bases:
ABCMixin for sampleable objects.
- abstract classmethod REQUIRED_COLUMNS(target=None)¶
- abstract annotate(observations, *, categories, background_category)¶
Annotate the sampleable with observations.
- Parameters:
- Return type:
- Returns:
The annotated sampleable.
- sample(extractor)¶
Extract features and labels (if also
AnnotatedMixin) for all available samples.
- sample_X(extractor)¶
Extract features for all available samples.
- Parameters:
extractor (
BaseExtractor[TypeVar(F, bound=Shaped)]) – The extractor to use for sampling.- Return type:
- Returns:
The extracted features.
- property size: int¶
Return the total number of available samples.
Also accessible via the
lenfunction.
- subsample(extractor, size, *, random_state=None, stratify=True, reset_previous_indices=False, exclude_previous_indices=False, store_indices=False, log=None)¶
Extract features and labels (if also
AnnotatedMixin) for a subset of samples.- Parameters:
extractor (
BaseExtractor[TypeVar(F, bound=Shaped)]) – The extractor to use for sampling.size (
int|float|Mapping[str|tuple[str,...],int|float]) – The number of samples to extract.random_state (
int|Generator|None, default:None) – The random state to use for sampling.stratify (
bool, default:True) – Whether to stratify the samples.reset_previous_indices (
bool, default:False) – Whether to reset the previous indices.exclude_previous_indices (
bool, default:False) – Whether to exclude the previous indices.store_indices (
bool, default:False) – Whether to store the indices.log (
Logger|None, default:None) – The logger to use for logging.
- Return type:
- Returns:
The extracted features and labels.
- class SamplingFunction(*args, **kwargs)¶
Bases:
ProtocolProtocol for functions that sample data from a sampleable.
- Parameters:
sampleable (
SampleableMixin) – The sampleable to sample from.extractor (
BaseExtractor) – The extractor to use for sampling.*args – Additional arguments to use within the function.
random_state (
Generator| int | None) – The random state to use for sampling.log (loguru.Logger | None) – The logger to use for logging.
**kwargs – Additional keyword arguments to use within the function.