Coverage for src/bob/fusion/base/algorithm/Weighted_Sum.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.6.0, created at 2024-07-13 01:00 +0200

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 Weighted_Sum(Algorithm): 

15 """weighted sum (default: mean)""" 

16 

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

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

19 self.weights = weights 

20 self.str["weights"] = weights 

21 

22 def fit(self, X, y): 

23 pass 

24 

25 def decision_function(self, scores): 

26 if self.weights is None: 

27 return numpy.mean(scores, axis=1) 

28 else: 

29 return numpy.sum(scores * self.weights, axis=1)