Ensemble
EnsembleBase
Bases: ABC
Base class for ensemble methods. Ensemble methods are used to combine the annotations of multiple annotators into a single annotation. The ensemble method is called with a list of annotations, where each annotation is a list of probabilities for each label. The ensemble method should return a single annotation, which is a list of probabilities for each label.
Source code in src/ensemble/ensemble.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
__call__(annotations, *args, **kwargs)
Making the ensemble method callable allows to also define functions as ensemble methods instead of classes. This is useful for ensemble methods that do not have any state.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
annotations |
List[Union[array, Annotation]]
|
|
required |
args |
|
()
|
|
kwargs |
|
{}
|
Returns:
Type | Description |
---|---|
Tuple[Union[List | array], int]
|
|
Source code in src/ensemble/ensemble.py
20 21 22 23 24 25 26 27 28 29 30 31 |
|
normalize(annotations)
staticmethod
Normalize the annotations. This method is used to bring the ensemble result into probability vectors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
annotations |
array
|
|
required |
Returns:
Type | Description |
---|---|
array
|
|
Source code in src/ensemble/ensemble.py
46 47 48 49 50 51 52 53 |
|
run(annotations)
Run the ensemble method. This method should be implemented by subclasses. The ensemble method is called with a list of annotations, where each annotation is a list of probabilities for each label. The ensemble method should return a single annotation, which is a list of probabilities for each label. The ensemble method should also return a boolean indicating whether the ensemble method was able to produce a valid annotation. If the ensemble method was not able to produce a valid annotation, the ensemble method should return the first annotation in the list of annotations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
annotations |
List[Annotation]
|
|
required |
Returns:
Type | Description |
---|---|
Tuple[Union[List | array], int]
|
|
Source code in src/ensemble/ensemble.py
33 34 35 36 37 38 39 40 41 42 43 44 |
|