SingleAnnotatorStreamQueryStrategy#
- class skactiveml.base.SingleAnnotatorStreamQueryStrategy(budget, random_state=None)[source]#
Bases:
QueryStrategyBase class for all stream-based active learning query strategies.
Stream query strategies have no target_type parameter, because they do not resolve the labels y themselves. A strategy consuming a classifier treats it as the target authority and supports single-output classification only. Label-free strategies are task-agnostic and declare the same capabilities as their pool-based counterparts.
- Parameters:
- budgetfloat or None
Specifies the ratio of labels which are allowed to be queried, with 0 < budget <= 1. If budget is None, the default budget 0.1 is used.
- random_stateint or RandomState instance or None, default=None
Controls the randomness of the estimator.
Methods
query(candidates, *args[, return_utilities])Determines for which candidate samples labels are to be queried.
update(candidates, queried_indices, *args[, ...])Updates the budget manager and the count for seen and queried labels.
Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
set_params(**params)Set the parameters of this estimator.
- abstract SingleAnnotatorStreamQueryStrategy.query(candidates, *args, return_utilities=False, **kwargs)[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_indiceslist of int or ndarray of shape (n_queried_indices,)
The indices of samples in candidates whose labels are queried, with 0 <= queried_indices < n_candidates.
- utilitiesnp.ndarray of shape (n_candidates,)
The utilities based on the query strategy. Only provided if return_utilities is True.
- abstract SingleAnnotatorStreamQueryStrategy.update(candidates, queried_indices, *args, budget_manager_param_dict=None, **kwargs)[source]#
Updates the budget manager and 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_indicesarray-like of shape (n_queried_indices,)
The indices of samples in candidates whose labels are queried, with 0 <= queried_indices < n_candidates.
- budget_manager_param_dictdict, default=None
Optional kwargs for budget_manager. If supplied, utilities must be a one-dimensional array with one value per candidate. Some budget managers, e.g., BalancedIncrementalQuantileFilter, require utilities. Strategies without a budget manager ignore it.
- Returns:
- selfSingleAnnotatorStreamQueryStrategy
The query strategy returns itself, after it is updated.
- SingleAnnotatorStreamQueryStrategy.get_metadata_routing()#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequestencapsulating routing information.
- SingleAnnotatorStreamQueryStrategy.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.
- SingleAnnotatorStreamQueryStrategy.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.
Examples using skactiveml.base.SingleAnnotatorStreamQueryStrategy#
Cognitive Dual-Query Strategy with Fixed-Uncertainty
Cognitive Dual-Query Strategy with Random Sampling
Cognitive Dual-Query Strategy with Randomized-Variable-Uncertainty
Cognitive Dual-Query Strategy with Variable-Uncertainty