module: multi_types¶
-
class
annotlib.multi_types.
MultiAnnotTypes
(annotator_types)[source]¶ Bases:
annotlib.base.BaseAnnot
This class enables to manage multiple types of annotators.
Parameters: - annotator_types: BaseAnnot | list, shape (n_annotators)
A single annotator or a list of annotators who are to be added.
Examples
>>> import numpy as np >>> from sklearn.datasets import load_iris >>> from annotlib import ClassifierBasedAnnot, ClusterBasedAnnot >>> X, y_true = load_iris(return_X_y=True) >>> # create two types of annotators >>> classifier_annotators = ClassifierBasedAnnot(X=X, y_true=y_true, n_annotators=3) >>> cluster_annotators = ClusterBasedAnnot(X=X, y_true=y_true, n_annotators=3) >>> annotator_types = [classifier_annotators, cluster_annotators] >>> # create instance of multiple annotator types >>> multiple_annotators = MultiAnnotTypes(annotator_types=annotator_types) >>> # there are 3+3=6 annotators >>> multiple_annotators.n_annotators() 6 >>> # ask 6 annotators for class labels of 10 samples >>> multiple_annotators.class_labels(X=X[0:10], query_value=10).shape (10, 6) >>> # check query values >>> multiple_annotators.n_queries() array([10, 10, 10, 10, 10, 10])
Attributes: - annotator_types_: list, shape (n_annotators)
List of added annotators.
-
add_annotators
(self, annotator_types)[source]¶ Method adds new annotators.
Parameters: - annotator_types: list, shape (n_annotators)
The annotator types to be added.
Returns: - self: sim_annotator_lib.multiple_annotator_types.MultiAnnotTypes
The instance itself.
-
class_labels
(self, X, annotator_ids=None, query_value=1, **kwargs)[source]¶ Method returning the class labels of the given samples.
Parameters: - X: array-like, shape (n_samples, n_features)
Samples whose class labels are queried.
- annotator_ids: array-like, shape (n_queried_annotators)
The indices of the annotators whose class labels are queried.
- query_value: int
The query value represents the increment of the query statistics of the queried annotators.
Returns: - Y: numpy.ndarray, shape (n_samples, n_annotators)
Class labels of the given samples which were provided by the queried annotators. The non queried annotators return np.nan values.
-
confidence_scores
(self, X, annotator_ids=None, **kwargs)[source]¶ Method returning the confidence scores for labelling the given samples.
Parameters: - X: array-like, shape (n_samples, n_features)
Samples whose class labels are queried.
- annotator_ids: array-like, shape (n_queried_annotators)
The indices of the annotators whose confidence scores are queried.
Returns: - C: numpy.ndarray, shape (n_samples, n_annotators)
Confidence scores of the queried annotators for labelling the given samples. The non queried annotators should return np.nan values.
-
n_annotators
(self)[source]¶ Method for computing the number of annotators.
Returns: - n_annotators: int
Number of annotators.
-
n_queries
(self)[source]¶ Method for computing the number of queries posed to an annotator.
Returns: - n_queries: numpy.ndarray, shape (n_annotators)
An entry n_queries_[a] indicates how many queries annotator a has processed.
-
queried_samples
(self)[source]¶ Abstract method for returning the samples for which the annotators were queried to provide class labels.
Returns: - X_queried: numpy.ndarray, shape (n_annotators, n_queried_samples, n_features)
An entry X_queried_[a] represents the samples for which the annotator a was queried to provide class labels.