mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-11 15:15:15 +02:00
[normalizer] only mean, because variance could be not Gaussian...
This commit is contained in:
parent
a3c8739f9e
commit
8cf11257b0
2 changed files with 9 additions and 12 deletions
|
|
@ -15,7 +15,7 @@ from parameterization.variational import VariationalPosterior
|
|||
from scipy.sparse.base import issparse
|
||||
|
||||
import logging
|
||||
from GPy.util.normalizer import GaussianNorm
|
||||
from GPy.util.normalizer import MeanNorm
|
||||
logger = logging.getLogger("GP")
|
||||
|
||||
class GP(Model):
|
||||
|
|
@ -31,7 +31,7 @@ class GP(Model):
|
|||
:param Norm normalizer:
|
||||
normalize the outputs Y.
|
||||
Prediction will be un-normalized using this normalizer.
|
||||
If normalizer is None, we will normalize using GaussianNorm.
|
||||
If normalizer is None, we will normalize using MeanNorm.
|
||||
If normalizer is False, no normalization will be done.
|
||||
|
||||
.. Note:: Multiple independent outputs are allowed using columns of Y
|
||||
|
|
@ -52,7 +52,7 @@ class GP(Model):
|
|||
logger.info("initializing Y")
|
||||
|
||||
if normalizer is None:
|
||||
self.normalizer = GaussianNorm()
|
||||
self.normalizer = MeanNorm()
|
||||
elif normalizer is False:
|
||||
self.normalizer = None
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -24,25 +24,22 @@ class Norm(object):
|
|||
Project the normalized object X into space of Y
|
||||
"""
|
||||
raise NotImplementedError
|
||||
def inverse_variance(self, var):
|
||||
return var
|
||||
def scaled(self):
|
||||
"""
|
||||
Whether this Norm object has been initialized.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
class GaussianNorm(Norm):
|
||||
class MeanNorm(Norm):
|
||||
def __init__(self):
|
||||
self.mean = None
|
||||
self.std = None
|
||||
def scale_by(self, Y):
|
||||
Y = np.ma.masked_invalid(Y, copy=False)
|
||||
self.mean = Y.mean(0).view(np.ndarray)
|
||||
self.std = Y.std(0).view(np.ndarray)
|
||||
self.std[self.std==0] = 1.
|
||||
def normalize(self, Y):
|
||||
return ((Y-self.mean)/self.std)
|
||||
return Y-self.mean
|
||||
def inverse_mean(self, X):
|
||||
return ((X*self.std)+self.mean)
|
||||
def inverse_variance(self, var):
|
||||
return (var*self.std**2)
|
||||
return X+self.mean
|
||||
def scaled(self):
|
||||
return self.mean is not None and self.std is not None
|
||||
return self.mean is not None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue