Coverage for src/bob/fusion/base/preprocessor/ZNorm.py: 60%
10 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
1import numpy as np
3from sklearn.preprocessing import StandardScaler
5# to fix the sphinx docs
6StandardScaler.__module__ = "sklearn.preprocessing"
9class ZNorm(StandardScaler):
10 """ZNorm feature scaler
11 This scaler works just like :any:`sklearn.preprocessing.StandardScaler` but
12 only takes the zero effort impostors into account when estimating the mean
13 and standard deviation. You should not use this scaler when PAD scores are
14 present.
15 """
17 def __init__(self, copy=True, **kwargs):
18 """Initialize self. See help(type(self)) for accurate signature."""
19 super(ZNorm, self).__init__(
20 copy=copy, with_mean=True, with_std=True, **kwargs
21 )
23 def fit(self, X, y=None):
24 """Estimates the mean and standard deviation of samples.
25 Only positive samples are used in estimation.
26 """
27 # the fitting is done only on negative samples
28 if y is not None:
29 X = np.asarray(X)[~y, ...]
30 return super(ZNorm, self).fit(X)