SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SparseInferenceBase.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) The Shogun Machine Learning Toolbox
3  * Written (W) 2015 Wu Lin
4  * Written (W) 2013 Roman Votyakov
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  * The views and conclusions contained in the software and documentation are those
28  * of the authors and should not be interpreted as representing official policies,
29  * either expressed or implied, of the Shogun Development Team.
30  *
31  */
32 
33 #ifndef CSPARSEINFERENCEBASE_H
34 #define CSPARSEINFERENCEBASE_H
35 
36 #include <shogun/lib/config.h>
37 
38 #ifdef HAVE_EIGEN3
39 
42 
43 namespace shogun
44 {
45 
73 {
74 public:
77 
87  CSparseInferenceBase(CKernel* kernel, CFeatures* features,
88  CMeanFunction* mean, CLabels* labels, CLikelihoodModel* model,
89  CFeatures* inducing_features);
90 
91  virtual ~CSparseInferenceBase();
92 
97  virtual EInferenceType get_inference_type() const { return INF_SPARSE; }
98 
103  virtual const char* get_name() const { return "SparseBaseInferenceMethod"; }
104 
109  virtual void set_inducing_features(CFeatures* feat)
110  {
111  REQUIRE(feat,"Input inducing features must be not empty\n");
112  CDotFeatures *lat_type=dynamic_cast<CDotFeatures *>(feat);
113  REQUIRE(lat_type, "Inducing features (%s) must be"
114  " DotFeatures or one of its subclasses\n", feat->get_name());
116  }
117 
123  {
126  CFeatures* inducing_features=new CDenseFeatures<float64_t>(out);
127  SG_REF(inducing_features);
128  return inducing_features;
129  }
130 
141  virtual SGVector<float64_t> get_alpha();
142 
155 
157  virtual void update()=0;
158 
165  virtual void set_inducing_noise(float64_t noise);
166 
172  virtual float64_t get_inducing_noise();
173 
180 
197 
214 
215 protected:
226  virtual void convert_features();
227 
230  virtual void check_features();
231 
233  virtual void check_members() const;
234 
236  virtual void update_train_kernel();
237 
246  const TParameter* param)=0;
247 
256  const TParameter* param)=0;
257 
266  const TParameter* param)=0;
267 
276  const TParameter* param)=0;
277 
302  const TParameter* param)=0;
303 
306 
309 
312 
315 
318 
321 
324 private:
326  void init();
327 };
328 }
329 #endif /* HAVE_EIGEN3 */
330 #endif /* CSPARSEINFERENCEBASE_H */
virtual const char * get_name() const =0
virtual SGVector< float64_t > get_derivative_wrt_mean(const TParameter *param)=0
virtual SGMatrix< float64_t > get_posterior_covariance()=0
virtual void check_members() const
virtual SGVector< float64_t > get_derivative_wrt_inducing_features(const TParameter *param)=0
SGVector< float64_t > m_ktrtr_diag
The Inference Method base class.
virtual SGVector< float64_t > get_derivative_wrt_inducing_noise(const TParameter *param)=0
virtual void set_inducing_features(CFeatures *feat)
virtual float64_t get_inducing_noise()
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:43
virtual EInferenceType get_inference_type() const
virtual SGMatrix< float64_t > get_cholesky()
parameter struct
#define REQUIRE(x,...)
Definition: SGIO.h:206
index_t num_cols
Definition: SGMatrix.h:378
An abstract class of the mean function.
Definition: MeanFunction.h:49
Features that support dot products among other operations.
Definition: DotFeatures.h:44
SGMatrix< float64_t > m_inducing_features
#define SG_REF(x)
Definition: SGObject.h:51
index_t num_rows
Definition: SGMatrix.h:376
virtual SGVector< float64_t > get_derivative_wrt_likelihood_model(const TParameter *param)=0
virtual SGVector< float64_t > get_derivative_wrt_inference_method(const TParameter *param)=0
virtual SGVector< float64_t > get_posterior_mean()=0
virtual const char * get_name() const
double float64_t
Definition: common.h:50
virtual void set_inducing_noise(float64_t noise)
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual CFeatures * get_inducing_features()
The class Features is the base class of all feature objects.
Definition: Features.h:68
The Kernel base class.
Definition: Kernel.h:158
SGMatrix< float64_t > get_computed_dot_feature_matrix()
The Fully Independent Conditional Training inference base class.
virtual SGVector< float64_t > get_derivative_wrt_kernel(const TParameter *param)=0
The Likelihood model base class.
virtual SGVector< float64_t > get_alpha()

SHOGUN Machine Learning Toolbox - Documentation