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

1#!/usr/bin/env python 

2 

3from __future__ import absolute_import, division 

4 

5import logging 

6 

7import numpy 

8 

9from .Algorithm import Algorithm 

10 

11logger = logging.getLogger(__name__) 

12 

13 

14class AND(Algorithm): 

15 """This algorithm fuses several systems with cascading.""" 

16 

17 def __init__(self, thresholds=None, **kwargs): 

18 super(AND, self).__init__(classifier=self, **kwargs) 

19 self.thresholds = thresholds 

20 self.str["thresholds"] = thresholds 

21 

22 def fit(self, X, y): 

23 pass 

24 

25 def decision_function(self, scores): 

26 if self.thresholds is None: 

27 ValueError("No threshold was specified.") 

28 

29 for i, th in enumerate(self.thresholds): 

30 mask = scores[:, i + 1] < th 

31 scores[mask, i + 1] = numpy.nan 

32 

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