improve the documentation of infer_newX

This commit is contained in:
Zhenwen Dai 2015-07-27 12:51:03 +01:00
parent ce3681a566
commit 1a141d9ce5
2 changed files with 11 additions and 4 deletions

View file

@ -473,16 +473,16 @@ class GP(Model):
self.inference_method.on_optimization_end() self.inference_method.on_optimization_end()
raise raise
def infer_newX(self, Y_new, optimize=True, ): def infer_newX(self, Y_new, optimize=True):
""" """
Infer the distribution of X for the new observed data *Y_new*. Infer X for the new observed data *Y_new*.
:param Y_new: the new observed data for inference :param Y_new: the new observed data for inference
:type Y_new: numpy.ndarray :type Y_new: numpy.ndarray
:param optimize: whether to optimize the location of new X (True by default) :param optimize: whether to optimize the location of new X (True by default)
:type optimize: boolean :type optimize: boolean
:return: a tuple containing the posterior estimation of X and the model that optimize X :return: a tuple containing the posterior estimation of X and the model that optimize X
:rtype: (:class:`~GPy.core.parameterization.variational.VariationalPosterior` or numpy.ndarray, :class:`~GPy.core.model.Model`) :rtype: (:class:`~GPy.core.parameterization.variational.VariationalPosterior` and numpy.ndarray, :class:`~GPy.core.model.Model`)
""" """
from ..inference.latent_function_inference.inferenceX import infer_newX from ..inference.latent_function_inference.inferenceX import infer_newX
return infer_newX(self, Y_new, optimize=optimize) return infer_newX(self, Y_new, optimize=optimize)

View file

@ -27,12 +27,19 @@ def infer_newX(model, Y_new, optimize=True, init='L2'):
class InferenceX(Model): class InferenceX(Model):
""" """
The class for inference of new X with given new Y. (do_test_latent) The model class for inference of new X with given new Y. (replacing the "do_test_latent" in Bayesian GPLVM)
It is a tiny inference model created from the original GP model. The kernel, likelihood (only Gaussian is supported at the moment)
and posterior distribution are taken from the original model.
For Regression models and GPLVM, a point estimate of the latent variable X will be inferred.
For Bayesian GPLVM, the variational posterior of X will be inferred.
X is inferred through a gradient optimization of the inference model.
:param model: the GPy model used in inference :param model: the GPy model used in inference
:type model: GPy.core.Model :type model: GPy.core.Model
:param Y: the new observed data for inference :param Y: the new observed data for inference
:type Y: numpy.ndarray :type Y: numpy.ndarray
:param init: the distance metric of Y for initializing X with the nearest neighbour.
:type init: 'L2', 'NCC' and 'rand'
""" """
def __init__(self, model, Y, name='inferenceX', init='L2'): def __init__(self, model, Y, name='inferenceX', init='L2'):
if np.isnan(Y).any() or getattr(model, 'missing_data', False): if np.isnan(Y).any() or getattr(model, 'missing_data', False):