FITCInferenceMethod.h

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Copyright (C) 2012 Jacob Walker
00008  *
00009  *  * Code adapted from Gaussian Process Machine Learning Toolbox
00010  * http://www.gaussianprocess.org/gpml/code/matlab/doc/
00011  *
00012  */
00013 
00014 #ifndef CFITCINFERENCEMETHOD_H_
00015 #define CFITCINFERENCEMETHOD_H_
00016 
00017 #include <shogun/lib/config.h>
00018 #ifdef HAVE_EIGEN3
00019 #ifdef HAVE_LAPACK
00020 
00021 #include <shogun/regression/gp/InferenceMethod.h>
00022 
00023 namespace shogun
00024 {
00025 
00041 class CFITCInferenceMethod: public CInferenceMethod
00042 {
00043 
00044 public:
00045 
00046     /*Default Constructor*/
00047     CFITCInferenceMethod();
00048 
00049     /* Constructor
00050      * @param kernel covariance function
00051      * @param features features to use in inference
00052      * @param mean mean function
00053      * @param labels labels of the features
00054      * @param model Likelihood model to use
00055      * @param latent features to use
00056      */
00057     CFITCInferenceMethod(CKernel* kernel, CFeatures* features,
00058             CMeanFunction* mean, CLabels* labels, CLikelihoodModel* model,
00059             CFeatures* latent_features);
00060 
00061     /*Destructor*/
00062     virtual ~CFITCInferenceMethod();
00063 
00073     virtual float64_t get_negative_marginal_likelihood();
00074 
00083     virtual CMap<TParameter*, SGVector<float64_t> > get_marginal_likelihood_derivatives(
00084             CMap<TParameter*, CSGObject*>& para_dict);
00085 
00095     virtual SGVector<float64_t> get_alpha();
00096 
00097 
00108     virtual SGMatrix<float64_t> get_cholesky();
00109 
00120     virtual SGVector<float64_t> get_diagonal_vector();
00121 
00127     virtual const char* get_name() const
00128     {
00129         return "FITCInferenceMethod";
00130     }
00131 
00132     /*Get the gradient
00133      *
00134      * @return Map of gradient. Keys are names of parameters, values are
00135      * values of derivative with respect to that parameter.
00136      */
00137     virtual CMap<TParameter*, SGVector<float64_t> > get_gradient(
00138             CMap<TParameter*, CSGObject*>& para_dict)
00139     {
00140         return get_marginal_likelihood_derivatives(para_dict);
00141     }
00142 
00143     /*Get the function value
00144      *
00145      * @return Vector that represents the function value
00146      */
00147     virtual SGVector<float64_t> get_quantity()
00148     {
00149         SGVector<float64_t> result(1);
00150         result[0] = get_negative_marginal_likelihood();
00151         return result;
00152     }
00153 
00154 protected:
00157     virtual void update_alpha();
00158     virtual void update_chol();
00159     virtual void update_train_kernel();
00160     virtual void update_all();
00161 
00162 private:
00163 
00164     void init();
00165 
00166 private:
00167 
00171     void check_members();
00172 
00173     /*Kernel matrix with noise*/
00174     SGMatrix<float64_t> m_kern_with_noise;
00175 
00176     /*noise of the latent variables*/
00177     float64_t m_ind_noise;
00178 
00179     /*Cholesky of Covariance of
00180      * latent features
00181      */
00182     SGMatrix<float64_t> m_chol_uu;
00183 
00184     /*Cholesky of Covariance of
00185      * latent features
00186      * and training features
00187      */
00188     SGMatrix<float64_t> m_chol_utr;
00189 
00190     /* Covariance matrix of latent
00191      * features
00192      */
00193     SGMatrix<float64_t> m_kuu;
00194 
00195     /* Covariance matrix of latent
00196      * features and training features
00197      */
00198     SGMatrix<float64_t> m_ktru;
00199 
00200     /* Diagonal of Training
00201      * kernel matrix + noise
00202      * - diagonal of the matrix
00203      * (m_chol_uu^{-1}*m_ktru)*
00204      * (m_chol_uu^(-1)*m_ktru)'
00205      * = V*V'
00206      */
00207     SGVector<float64_t> m_dg;
00208 
00209     /*Labels adjusted for
00210      * noise and means
00211      */
00212     SGVector<float64_t> m_r;
00213 
00214     /* Solves the equation
00215      * V*r = m_chol_utr
00216      */
00217     SGVector<float64_t> m_be;
00218 
00219 
00220 
00221 };
00222 
00223 }
00224 #endif // HAVE_EIGEN3
00225 #endif // HAVE_LAPACK
00226 
00227 #endif /* CFITCInferenceMethod_H_ */
00228 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation