pusion.core.cosine_similarity_combiner¶
- class pusion.core.cosine_similarity_combiner.CosineSimilarityCombiner¶
Bases:
pusion.core.combiner.UtilityBasedCombiner
The
CosineSimilarityCombiner
considers the classification assignments to \(\ell\) classes as vectors from an \(\ell\)-dimensional vector space. The normalized cosine-similarity measure between two vectors \(x\) and \(y\) is calculated as\[cos(x,y) = \dfrac{x\cdot y}{|x||y|}\ .\]The cosine-similarity is calculated pairwise and accumulated for each classifier for one specific sample. The fusion is represented by a classifier which shows the most similar classification output to the output of all competing classifiers.
- combine(decision_tensor)¶
Combine decision outputs with as an output that accommodates the highest cosine-similarity to the output of all competing classifiers. In other words, the best representative classification output among the others is selected according to the highest cumulative cosine-similarity. This method supports both, continuous and crisp classification outputs.
- Parameters
decision_tensor – numpy.array of shape (n_classifiers, n_samples, n_classes). Tensor of either crisp or continuous decision outputs by different classifiers per sample.
- Returns
A matrix (numpy.array) of either crisp or continuous class assignments which represents fused decisions obtained by the highest cumulative cosine-similarity. Axis 0 represents samples and axis 1 the class labels which are aligned with axis 2 in
decision_tensor
input tensor.
- class pusion.core.cosine_similarity_combiner.CRCosineSimilarity¶
Bases:
pusion.core.cosine_similarity_combiner.CosineSimilarityCombiner
The
CRCosineSimilarity
is a modification ofCosineSimilarityCombiner
that also supports complementary-redundant decision outputs. Therefore the input is transformed, such that all missing classification assignments are considered as 0, respectively. To callcombine()
a coverage needs to be set first by the inheritedset_coverage()
method.- combine(decision_outputs)¶
Combine complementary-redundant decision outputs with as an output that accommodates the highest cosine-similarity to the output of all competing classifiers. In other words, the best representative classification output among the others is selected according to the highest cumulative cosine-similarity. This method supports both, continuous and crisp classification outputs.
- Parameters
decision_outputs – list of numpy.array matrices, each of shape (n_samples, n_classes’), where n_classes’ is classifier-specific and described by the coverage. Each matrix corresponds to one of n_classifiers classifiers and contains crisp or continuous decision outputs per sample.
- Returns
A matrix (numpy.array) of crisp or continuous class assignments which represents fused decisions. Axis 0 represents samples and axis 1 the class labels which are aligned with axis 2 in
decision_tensor
input tensor.