Skip to content

Avg

AverageEnsemble

Bases: EnsembleBase

Ensemble method that averages the annotations.

Source code in src/ensemble/avg.py
 9
10
11
12
13
14
15
16
17
18
19
20
class AverageEnsemble(EnsembleBase):
    """
    Ensemble method that averages the annotations.
    """

    def run(self, annotations: List[Annotation]) -> Annotation:
        annotated = np.array([x.distribution for x in annotations if not x.unannotated])
        if annotated:
            mean = np.mean(annotated, axis=0)
            return Annotation(distribution=mean.tolist(), unannotated=0)

        return Annotation(distribution=annotations[0].distribution, unannotated=1)