SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FITCInferenceMethod.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Copyright (C) 2012 Jacob Walker
8  *
9  * * Code adapted from Gaussian Process Machine Learning Toolbox
10  * http://www.gaussianprocess.org/gpml/code/matlab/doc/
11  *
12  */
13 
14 #ifndef CFITCINFERENCEMETHOD_H_
15 #define CFITCINFERENCEMETHOD_H_
16 
17 #include <shogun/lib/config.h>
18 #ifdef HAVE_EIGEN3
19 #ifdef HAVE_LAPACK
20 
22 
23 namespace shogun
24 {
25 
42 {
43 
44 public:
45 
46  /*Default Constructor*/
48 
49  /* Constructor
50  * @param kernel covariance function
51  * @param features features to use in inference
52  * @param mean mean function
53  * @param labels labels of the features
54  * @param model Likelihood model to use
55  * @param latent features to use
56  */
57  CFITCInferenceMethod(CKernel* kernel, CFeatures* features,
58  CMeanFunction* mean, CLabels* labels, CLikelihoodModel* model,
59  CFeatures* latent_features);
60 
61  /*Destructor*/
62  virtual ~CFITCInferenceMethod();
63 
74 
85 
96 
97 
109 
121 
127  inline virtual const char* get_name() const
128  {
129  return "FITCInferenceMethod";
130  }
131 
132  /*Get the gradient
133  *
134  * @return Map of gradient. Keys are names of parameters, values are
135  * values of derivative with respect to that parameter.
136  */
139  {
140  return get_marginal_likelihood_derivatives(para_dict);
141  }
142 
143  /*Get the function value
144  *
145  * @return Vector that represents the function value
146  */
148  {
149  SGVector<float64_t> result(1);
150  result[0] = get_negative_marginal_likelihood();
151  return result;
152  }
153 
154 protected:
157  virtual void update_alpha();
158  virtual void update_chol();
159  virtual void update_train_kernel();
160  virtual void update_all();
161 
162 private:
163 
164  void init();
165 
166 private:
167 
171  void check_members();
172 
173  /*Kernel matrix with noise*/
174  SGMatrix<float64_t> m_kern_with_noise;
175 
176  /*noise of the latent variables*/
177  float64_t m_ind_noise;
178 
179  /*Cholesky of Covariance of
180  * latent features
181  */
182  SGMatrix<float64_t> m_chol_uu;
183 
184  /*Cholesky of Covariance of
185  * latent features
186  * and training features
187  */
188  SGMatrix<float64_t> m_chol_utr;
189 
190  /* Covariance matrix of latent
191  * features
192  */
193  SGMatrix<float64_t> m_kuu;
194 
195  /* Covariance matrix of latent
196  * features and training features
197  */
198  SGMatrix<float64_t> m_ktru;
199 
200  /* Diagonal of Training
201  * kernel matrix + noise
202  * - diagonal of the matrix
203  * (m_chol_uu^{-1}*m_ktru)*
204  * (m_chol_uu^(-1)*m_ktru)'
205  * = V*V'
206  */
207  SGVector<float64_t> m_dg;
208 
209  /*Labels adjusted for
210  * noise and means
211  */
213 
214  /* Solves the equation
215  * V*r = m_chol_utr
216  */
217  SGVector<float64_t> m_be;
218 
219 
220 
221 };
222 
223 }
224 #endif // HAVE_EIGEN3
225 #endif // HAVE_LAPACK
226 
227 #endif /* CFITCInferenceMethod_H_ */
228 

SHOGUN Machine Learning Toolbox - Documentation