skactiveml.stream.StreamRandomSampling#
- class skactiveml.stream.StreamRandomSampling(allow_exceeding_budget=True, budget=None, random_state=None)[source]#
Bases:
SingleAnnotatorStreamQueryStrategy
Random Sampling for Data Streams.
The RandomSampling strategy queries labels completely randomly. The probability to query a sample is dependent on the budget specified in the budget manager. Given a budget of 10%, the utility exceeds 0.9 (1-0.1) with a probability of 10%. samples are queried regardless of their position in the feature space and disregards any information about the sample. Thus, it should only be used as a baseline strategy. The allow_exceeding_budget parameter allows to configure the strategy to strictly adhere to a given budget.
- Parameters
- allow_exceeding_budgetbool, default=True
If True, the query strategy is allowed to exceed it’s budget as long as the average number of queries will be within the budget. If False, queries are not allowed if the budget is exhausted.
- budgetfloat, default=None
The budget which models the budgeting constraint used in the stream-based active learning setting.
- random_stateint or RandomState instance or None, 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])Determines for which candidate samples labels are to be queried.
set_params
(**params)Set the parameters of this estimator.
update
(candidates, queried_indices)Updates the count for seen and queried labels.
- 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]#
Determines for which candidate samples labels are to be queried.
The query startegy determines the most useful samples in candidates, which can be acquired within the budgeting constraint specified by budget. Please note that, this method does not change the internal state of the query strategy. To adapt the query strategy to the selected candidates, use update(…).
- Parameters
- candidates{array-like, sparse matrix} of shape (n_candidates, n_features)
The samples which may be queried. Sparse matrices are accepted only if they are supported by the base query strategy.
- return_utilitiesbool, default=False
If True, also return the utilities based on the query strategy.
- Returns
- queried_indicesnp.ndarray of shape (n_queried_indices,)
The indices of samples in candidates whose labels are queried, with 0 <= queried_indices <= n_candidates.
- utilities: np.ndarray of shape (n_candidates,),
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 count for seen and queried labels. This function should be used in conjunction with the query function.
- Parameters
- candidates{array-like, sparse matrix} of shape (n_candidates, n_features)
The samples which may be queried. Sparse matrices are accepted only if they are supported by the base query strategy.
- queried_indicesnp.ndarray of shape (n_queried_indices,)
The indices of samples in candidates whose labels are queried, with 0 <= queried_indices <= n_candidates.
- Returns
- selfSingleAnnotatorStreamQueryStrategy
The query strategy returns itself, after it is updated.