alpbench.pipeline.ActiveLearningPipeline¶
Classes
|
Active Learning Pipeline |
- class alpbench.pipeline.ActiveLearningPipeline.ActiveLearningPipeline(learner, query_strategy, initializer=None, observer_list=None, init_budget=None, num_iterations=10, num_queries_per_iteration=10, initially_labeled_indices=None)[source]¶
Bases:
objectActive Learning Pipeline
This class implements an active learning pipeline that can be used to train a model on a given labeled dataset and iteratively query an oracle for additional labels to improve the model’s performance. The pipeline consists of an initializer, a learner, a query strategy, and an observer. The initializer is used to select data points from unlabeled data to be labeled by the oracle in the first iteration. The learner is the model that is trained on labeled data. The query strategy is used to select data points from the unlabeled dataset to be labeled by the oracle in subsequent iterations. The observer is used to log the data and model at each iteration.
- Parameters:
learner – The learner that is trained on the labeled data.
query_strategy – The query strategy used to select data points from the unlabeled dataset to be labeled by the oracle.
initializer – The initializer used to select data points from the unlabeled dataset to be labeled by the oracle in the first iterations.
observer_list – A list of observers that are used to log the data and model at each iteration.
init_budget – The budget for sampling data points with the initialization strategy.
num_iterations – The number of active learning rounds to carry out alternating between learning and querying the oracle.
num_queries_per_iteration – The number of data points to select in every active learning iteration to be labeled by the oracle.
- initializer¶
The initializer used to select data points from the unlabeled dataset to be labeled by the oracle in the first iteration.
- learner¶
The learner that is trained on the labeled data.
- query_strategy¶
The query strategy used to select data points from the unlabeled dataset to be labeled by the oracle.
- observer_list¶
A list of observers that are used to log the data and model at each iteration.
- init_budget¶
The budget for sampling data points with the initialization strategy.
- num_iterations¶
The number of active learning rounds to carry out alternating between learning and querying the oracle.
- num_queries_per_iteration¶
The number of data points to select in every active learning iteration to be labeled by the oracle.
- active_fit(X_l, y_l, X_u, oracle)[source]¶
Fits the active learning pipeline. This involves fitting the learner on the current labeled data, querying instances from the pool of unlabeled data, forwarding them to the oracle for labeling, updating the labeled data with the queried instances and their corresponding labels and repeating the process for the given number of iterations. The performances and labeling statistics are logged at each iteration.
- Parameters:
X_l (np.ndarray) – The labeled data.
y_l (np.ndarray) – The labels of the labeled data.
X_u (np.ndarray) – The unlabeled data.
oracle (Oracle) – The oracle used to query the true labels of the data.
- Returns:
None