skactiveml.stream.PeriodicSampling#
- class skactiveml.stream.PeriodicSampling(budget=None, random_state=None)[source]#
Bases:
SingleAnnotatorStreamQueryStrategy
The PeriodicSampling samples instances periodically. The length of that period is determined by the budget specified in the budgetmanager. For instance, a budget of 25% would result in the PeriodicSampling sampling every fourth instance. The main idea behind this query strategy is to exhaust a given budget as soon it is available. Instances are queried regardless of their position in the feature space. As this query strategy disregards any information about the instance. Thus, it should only be used as a baseline strategy.
- Parameters
- budgetfloat, optional (default=None)
The budget which models the budgeting constraint used in the stream-based active learning setting.
- random_stateint, RandomState instance, optional (default=None)
Controls the randomness of the estimator.
Methods
Get metadata routing of this object.
get_params
([deep])Get parameters for this estimator.
query
(candidates[, return_utilities])Ask the query strategy which instances in candidates to acquire.
set_params
(**params)Set the parameters of this estimator.
update
(candidates, queried_indices)Updates the budget manager and the count for seen and queried instances
- get_metadata_routing()#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns
- routingMetadataRequest
A
MetadataRequest
encapsulating routing information.
- get_params(deep=True)#
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.
- query(candidates, return_utilities=False)[source]#
Ask the query strategy which instances in candidates to acquire.
This query strategy only evaluates the time each instance arrives at. The utilities returned, when return_utilities is set to True, are either 0 (the instance is not queried) or 1 (the instance is queried). Please note that, when the decisions from this function may differ from the final sampling, simulate=True can set, so that the query strategy can be updated later with update(…) with the final sampling. This is especially helpful, when developing wrapper query strategies.
- Parameters
- candidatesarray-like or sparse matrix of shape
- (n_samples, n_features)
The instances which may be queried. Sparse matrices are accepted only if they are supported by the base query strategy.
- return_utilitiesbool, optional (default=False)
If true, also return the utilities based on the query strategy. The default is False.
- Returns
- queried_indicesndarray of shape (n_queried_instances,)
The indices of instances in candidates which should be queried, with 0 <= n_queried_instances <= n_samples.
- utilities: ndarray of shape (n_samples,), optional
The utilities based on the query strategy. Only provided if return_utilities is True.
- set_params(**params)#
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.
- update(candidates, queried_indices)[source]#
Updates the budget manager and the count for seen and queried instances
- Parameters
- candidatesarray-like or sparse matrix of shape
- (n_samples, n_features)
The instances which could be queried. Sparse matrices are accepted only if they are supported by the base query strategy.
- queried_indicesarray-like of shape (n_samples,)
Indicates which instances from candidates have been queried.
- Returns
- selfPeriodicSampling
The PeriodicSampler returns itself, after it is updated.