SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
EPInferenceMethod.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) The Shogun Machine Learning Toolbox
3  * Written (W) 2013 Roman Votyakov
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright notice, this
10  * list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
19  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * The views and conclusions contained in the software and documentation are those
27  * of the authors and should not be interpreted as representing official policies,
28  * either expressed or implied, of the Shogun Development Team.
29  *
30  *
31  * Based on ideas from GAUSSIAN PROCESS REGRESSION AND CLASSIFICATION Toolbox
32  * http://www.gaussianprocess.org/gpml/code/matlab/doc/
33  */
34 #ifndef _EPINFERENCEMETHOD_H_
35 #define _EPINFERENCEMETHOD_H_
36 
37 #include <shogun/lib/config.h>
38 
39 #ifdef HAVE_EIGEN3
40 
42 
43 namespace shogun
44 {
45 
54 {
55 public:
58 
67  CEPInferenceMethod(CKernel* kernel, CFeatures* features, CMeanFunction* mean,
68  CLabels* labels, CLikelihoodModel* model);
69 
70  virtual ~CEPInferenceMethod();
71 
76  virtual EInferenceType get_inference_type() const { return INF_EP; }
77 
82  virtual const char* get_name() const { return "EPInferenceMethod"; }
83 
90 
103 
126  virtual SGVector<float64_t> get_alpha();
127 
143 
156 
178 
199 
204  virtual float64_t get_tolerance() const { return m_tol; }
205 
210  virtual void set_tolerance(const float64_t tol) { m_tol=tol; }
211 
216  virtual uint32_t get_min_sweep() const { return m_min_sweep; }
217 
222  virtual void set_min_sweep(const uint32_t min_sweep) { m_min_sweep=min_sweep; }
223 
228  virtual uint32_t get_max_sweep() const { return m_max_sweep; }
229 
234  virtual void set_max_sweep(const uint32_t max_sweep) { m_max_sweep=max_sweep; }
235 
240  virtual bool supports_binary() const
241  {
242  check_members();
243  return m_model->supports_binary();
244  }
245 
247  virtual void update();
248 
249 protected:
251  virtual void compute_gradient();
252 
254  virtual void update_alpha();
255 
257  virtual void update_chol();
258 
260  virtual void update_approx_cov();
261 
263  virtual void update_approx_mean();
264 
266  virtual void update_negative_ml();
267 
271  virtual void update_deriv();
272 
281  const TParameter* param);
282 
291  const TParameter* param);
292 
301  const TParameter* param);
302 
311  const TParameter* param);
312 
313 private:
314  void init();
315 
316 private:
318  SGVector<float64_t> m_mu;
319 
321  SGMatrix<float64_t> m_Sigma;
322 
324  float64_t m_nlZ;
325 
329  SGVector<float64_t> m_tnu;
330 
334  SGVector<float64_t> m_ttau;
335 
337  SGVector<float64_t> m_sttau;
338 
340  float64_t m_tol;
341 
343  uint32_t m_min_sweep;
344 
346  uint32_t m_max_sweep;
347 
349 };
350 }
351 #endif /* HAVE_EIGEN3 */
352 #endif /* _EPINFERENCEMETHOD_H_ */
virtual SGVector< float64_t > get_diagonal_vector()
virtual SGVector< float64_t > get_alpha()
virtual uint32_t get_max_sweep() const
The Inference Method base class.
virtual void set_tolerance(const float64_t tol)
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:43
virtual SGMatrix< float64_t > get_posterior_covariance()
virtual EInferenceType get_inference_type() const
parameter struct
virtual float64_t get_negative_log_marginal_likelihood()
An abstract class of the mean function.
Definition: MeanFunction.h:49
virtual SGVector< float64_t > get_derivative_wrt_kernel(const TParameter *param)
virtual SGVector< float64_t > get_posterior_mean()
virtual uint32_t get_min_sweep() const
virtual float64_t get_tolerance() const
virtual SGVector< float64_t > get_derivative_wrt_mean(const TParameter *param)
double float64_t
Definition: common.h:50
virtual bool supports_binary() const
virtual void set_max_sweep(const uint32_t max_sweep)
virtual void set_min_sweep(const uint32_t min_sweep)
virtual SGVector< float64_t > get_derivative_wrt_likelihood_model(const TParameter *param)
static CEPInferenceMethod * obtain_from_generic(CInferenceMethod *inference)
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual SGVector< float64_t > get_derivative_wrt_inference_method(const TParameter *param)
Class of the Expectation Propagation (EP) posterior approximation inference method.
The class Features is the base class of all feature objects.
Definition: Features.h:68
virtual void check_members() const
The Kernel base class.
Definition: Kernel.h:158
virtual SGMatrix< float64_t > get_cholesky()
virtual const char * get_name() const
virtual bool supports_binary() const
The Likelihood model base class.
CLikelihoodModel * m_model

SHOGUN Machine Learning Toolbox - Documentation