SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SparseInference.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 CSPARSEINFERENCE_H
34 #define CSPARSEINFERENCE_H
35 
36 #include <shogun/lib/config.h>
37 
38 
41 
42 namespace shogun
43 {
44 
72 {
73 public:
76 
86  CSparseInference(CKernel* kernel, CFeatures* features,
87  CMeanFunction* mean, CLabels* labels, CLikelihoodModel* model,
88  CFeatures* inducing_features);
89 
90  virtual ~CSparseInference();
91 
96  virtual EInferenceType get_inference_type() const { return INF_SPARSE; }
97 
102  virtual const char* get_name() const { return "SparseBaseInferenceMethod"; }
103 
108  virtual void set_inducing_features(CFeatures* feat)
109  {
110  REQUIRE(feat,"Input inducing features must be not empty\n");
111  CDotFeatures *lat_type=dynamic_cast<CDotFeatures *>(feat);
112  REQUIRE(lat_type, "Inducing features (%s) must be"
113  " DotFeatures or one of its subclasses\n", feat->get_name());
115  }
116 
122  {
125  CFeatures* inducing_features=new CDenseFeatures<float64_t>(out);
126  SG_REF(inducing_features);
127  return inducing_features;
128  }
129 
140  virtual SGVector<float64_t> get_alpha();
141 
154 
156  virtual void update()=0;
157 
164  virtual void set_inducing_noise(float64_t noise);
165 
171  virtual float64_t get_inducing_noise();
172 
179 
196 
213 
214 protected:
225  virtual void convert_features();
226 
229  virtual void check_features();
230 
232  virtual void check_members() const;
233 
235  virtual void update_train_kernel();
236 
245  const TParameter* param)=0;
246 
255  const TParameter* param)=0;
256 
265  const TParameter* param)=0;
266 
275  const TParameter* param)=0;
276 
301  const TParameter* param)=0;
302 
305 
308 
311 
314 
317 
320 
323 private:
325  void init();
326 };
327 }
328 #endif /* CSPARSEINFERENCE_H */
virtual const char * get_name() const =0
virtual SGVector< float64_t > get_derivative_wrt_inducing_noise(const TParameter *param)=0
virtual SGVector< float64_t > get_derivative_wrt_likelihood_model(const TParameter *param)=0
virtual void set_inducing_features(CFeatures *feat)
virtual const char * get_name() const
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:43
SGVector< float64_t > m_mu
virtual SGVector< float64_t > get_derivative_wrt_mean(const TParameter *param)=0
parameter struct
virtual void set_inducing_noise(float64_t noise)
#define REQUIRE(x,...)
Definition: SGIO.h:206
index_t num_cols
Definition: SGMatrix.h:376
An abstract class of the mean function.
Definition: MeanFunction.h:49
Features that support dot products among other operations.
Definition: DotFeatures.h:44
#define SG_REF(x)
Definition: SGObject.h:54
virtual void check_members() const
virtual SGVector< float64_t > get_derivative_wrt_inference_method(const TParameter *param)=0
index_t num_rows
Definition: SGMatrix.h:374
virtual SGMatrix< float64_t > get_posterior_covariance()=0
virtual EInferenceType get_inference_type() const
virtual void update_train_kernel()
virtual SGMatrix< float64_t > get_cholesky()
double float64_t
Definition: common.h:50
SGMatrix< float64_t > m_Sigma
EInferenceType
Definition: Inference.h:53
virtual CFeatures * get_inducing_features()
virtual void convert_features()
SGMatrix< float64_t > m_kuu
virtual SGVector< float64_t > get_derivative_wrt_kernel(const TParameter *param)=0
virtual SGVector< float64_t > get_alpha()
SGVector< float64_t > m_ktrtr_diag
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The Inference Method base class.
Definition: Inference.h:81
SGMatrix< float64_t > m_inducing_features
virtual SGVector< float64_t > get_derivative_wrt_inducing_features(const TParameter *param)=0
The class Features is the base class of all feature objects.
Definition: Features.h:68
virtual float64_t get_inducing_noise()
The Kernel base class.
Definition: Kernel.h:159
SGMatrix< float64_t > m_ktru
virtual void update()=0
The Fully Independent Conditional Training inference base class.
SGMatrix< float64_t > get_computed_dot_feature_matrix()
The Likelihood model base class.
virtual SGVector< float64_t > get_posterior_mean()=0

SHOGUN Machine Learning Toolbox - Documentation