skactiveml.stream.CognitiveDualQueryStrategyFixUn#
- class skactiveml.stream.CognitiveDualQueryStrategyFixUn(budget=None, density_threshold=1, cognition_window_size=10, dist_func=None, dist_func_dict=None, random_state=None, force_full_budget=False)[source]#
Bases:
CognitiveDualQueryStrategy
This class implements the CognitiveDualQueryStrategy strategy with FixedUncertainty. The CognitiveDualQueryStrategy strategy is an extension to the uncertainty based query strategies proposed by Žliobaitė et al. [2] and follows the same idea as StreamDensityBasedAL [3] where queries for labels is only allowed if the local density around the corresponding instance is sufficiently high. The authors propose the use of a cognitive window that monitors the most representative samples within a data stream.
- Parameters
- budgetfloat, optional (default=None)
The budget which models the budgeting constraint used in the stream-based active learning setting.
- budget_managerBudgetManager, optional (default=None)
The BudgetManager which models the budgeting constraint used in the stream-based active learning setting. if set to None, FixedUncertaintyBudgetManager will be used by default. The budget manager will be initialized based on the following conditions:
If only a budget is given the default budget manager is initialized with the given budget. If only a budget manager is given use the budget manager. If both are not given the default budget manager with the default budget. If both are given and the budget differs from budgetmanager.budget a warning is thrown.
- density_thresholdint, optional (default=1)
Determines the local density factor size that needs to be reached in order to sample the candidate.
- cognition_window_sizeint, optional (default=10)
Determines the size of the cognition window
- random_stateint, RandomState instance, optional (default=None)
Controls the randomness of the estimator.
- dist_funccallable, optional (default=None)
The distance function used to calculate the distances within the local density window. If None use sklearn.metrics.pairwise.pairwise_distances
- force_full_budgetbool, optional (default=False)
If true, tries to utilize the full budget. The paper doesn’t update the budget manager if the locale density factor is 0
See also
budgetmanager.FixedUncertaintyBudgetManager
The default budget manager
budgetmanager.EstimatedBudgetZliobaite
The base class for FixedUncertaintyBudgetManager
References
- [1] Liu, S., Xue, S., Wu, J., Zhou, C., Yang, J., Li, Z., & Cao, J. (2021).
Online Active Learning for Drifting Data Streams. IEEE Transactions on Neural Networks and Learning Systems, 1-15.
- [2] Žliobaitė, I., Bifet, A., Pfahringer, B., & Holmes, G. (2014). Active
Learning With Drifting Streaming Data. IEEE Transactions on Neural Networks and Learning Systems, 25(1), 27-39.
- [3] Ienco, D., Pfahringer, B., & Zliobaitė, I. (2014). High density-focused
uncertainty sampling for active learning over evolving stream data. In BigMine 2014 (pp. 133-148).
Methods
Get metadata routing of this object.
get_params
([deep])Get parameters for this estimator.
query
(candidates, clf[, X, y, ...])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, clf, X=None, y=None, sample_weight=None, fit_clf=False, return_utilities=False)#
Ask the query strategy which instances in candidates to acquire.
Please note that, when the decisions from this function may differ from the final sampling, so the query strategy can be updated later with update(…) with the final sampling.
- Parameters
- candidates{array-like, 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.
- clfSkactivemlClassifier
Model implementing the methods fit and predict_freq.
- Xarray-like of shape (n_samples, n_features), optional
- (default=None)
Input samples used to fit the classifier.
- yarray-like of shape (n_samples), optional (default=None)
Labels of the input samples ‘X’. There may be missing labels.
- sample_weightarray-like of shape (n_samples,), optional
Sample weights for X, used to fit the clf.
- fit_clfbool, optional (default=False)
If true, refit the classifier also requires X and y to be given.
- 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, budget_manager_param_dict=None)#
Updates the budget manager and the count for seen and queried instances
- Parameters
- candidates{array-like, 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.
- budget_manager_param_dictkwargs, optional (default=None)
Optional kwargs for budget_manager.
- Returns
- selfCognitiveDualQueryStrategy
The CognitiveDualQueryStrategy returns itself, after it is updated.
Examples using skactiveml.stream.CognitiveDualQueryStrategyFixUn
#

Cognitive Dual-Query Strategy with Fixed-Uncertainty