Coverage for src/bob/fusion/base/algorithm/AND.py: 0%
22 statements
« prev ^ index » next coverage.py v7.6.5, created at 2024-11-14 22:15 +0100
« prev ^ index » next coverage.py v7.6.5, created at 2024-11-14 22:15 +0100
1#!/usr/bin/env python
3from __future__ import absolute_import, division
5import logging
7import numpy
9from .Algorithm import Algorithm
11logger = logging.getLogger(__name__)
14class AND(Algorithm):
15 """This algorithm fuses several systems with cascading."""
17 def __init__(self, thresholds=None, **kwargs):
18 super(AND, self).__init__(classifier=self, **kwargs)
19 self.thresholds = thresholds
20 self.str["thresholds"] = thresholds
22 def fit(self, X, y):
23 pass
25 def decision_function(self, scores):
26 if self.thresholds is None:
27 ValueError("No threshold was specified.")
29 for i, th in enumerate(self.thresholds):
30 mask = scores[:, i + 1] < th
31 scores[mask, i + 1] = numpy.nan
33 mask = numpy.sum(numpy.isnan(scores[:, 1:]), axis=1, dtype=bool)
34 new_scores = numpy.array(scores[0])
35 new_scores[mask] = numpy.finfo("float16").min
36 return new_scores