SHOGUN  4.2.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 
41 
42 namespace shogun
43 {
44 
53 {
54 public:
57 
66  CEPInferenceMethod(CKernel* kernel, CFeatures* features, CMeanFunction* mean,
67  CLabels* labels, CLikelihoodModel* model);
68 
69  virtual ~CEPInferenceMethod();
70 
75  virtual EInferenceType get_inference_type() const { return INF_EP; }
76 
81  virtual const char* get_name() const { return "EPInferenceMethod"; }
82 
89 
102 
125  virtual SGVector<float64_t> get_alpha();
126 
142 
155 
177 
198 
203  virtual float64_t get_tolerance() const { return m_tol; }
204 
209  virtual void set_tolerance(const float64_t tol) { m_tol=tol; }
210 
215  virtual uint32_t get_min_sweep() const { return m_min_sweep; }
216 
221  virtual void set_min_sweep(const uint32_t min_sweep) { m_min_sweep=min_sweep; }
222 
227  virtual uint32_t get_max_sweep() const { return m_max_sweep; }
228 
233  virtual void set_max_sweep(const uint32_t max_sweep) { m_max_sweep=max_sweep; }
234 
239  virtual bool supports_binary() const
240  {
241  check_members();
242  return m_model->supports_binary();
243  }
244 
246  virtual void update();
247 
252  virtual void register_minimizer(Minimizer* minimizer);
253 protected:
255  virtual void compute_gradient();
256 
258  virtual void update_alpha();
259 
261  virtual void update_chol();
262 
264  virtual void update_approx_cov();
265 
267  virtual void update_approx_mean();
268 
270  virtual void update_negative_ml();
271 
275  virtual void update_deriv();
276 
285  const TParameter* param);
286 
295  const TParameter* param);
296 
305  const TParameter* param);
306 
315  const TParameter* param);
316 
317 private:
318  void init();
319 
320 private:
322  SGVector<float64_t> m_mu;
323 
325  SGMatrix<float64_t> m_Sigma;
326 
328  float64_t m_nlZ;
329 
333  SGVector<float64_t> m_tnu;
334 
338  SGVector<float64_t> m_ttau;
339 
341  SGVector<float64_t> m_sttau;
342 
344  float64_t m_tol;
345 
347  uint32_t m_min_sweep;
348 
350  uint32_t m_max_sweep;
351 
353 };
354 }
355 #endif /* _EPINFERENCEMETHOD_H_ */
virtual SGVector< float64_t > get_diagonal_vector()
virtual SGVector< float64_t > get_alpha()
virtual uint32_t get_max_sweep() const
virtual void set_tolerance(const float64_t tol)
static CEPInferenceMethod * obtain_from_generic(CInference *inference)
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
EInferenceType
Definition: Inference.h:53
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)
virtual void register_minimizer(Minimizer *minimizer)
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)
The Inference Method base class.
Definition: Inference.h:81
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
The Kernel base class.
Definition: Kernel.h:159
The minimizer base class.
Definition: Minimizer.h:43
virtual SGMatrix< float64_t > get_cholesky()
virtual const char * get_name() const
CLikelihoodModel * m_model
Definition: Inference.h:475
virtual bool supports_binary() const
The Likelihood model base class.
virtual void check_members() const
Definition: Inference.cpp:322

SHOGUN Machine Learning Toolbox - Documentation