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
« prev ^ index » next coverage.py v7.6.0, created at 2024-07-13 01:00 +0200
1#!/usr/bin/env python
3from __future__ import absolute_import, division
5import logging
7import numpy
9from .Algorithm import Algorithm
11logger = logging.getLogger(__name__)
14class Weighted_Sum(Algorithm):
15 """weighted sum (default: mean)"""
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
22 def fit(self, X, y):
23 pass
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)