SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
InferenceMethod.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  * Written (W) 2013 Roman Votyakov
8  * Written (W) 2013-2014 Heiko Strathmann
9  * Copyright (C) 2012 Jacob Walker
10  * Copyright (C) 2013 Roman Votyakov
11  */
12 
13 #ifndef CINFERENCEMETHOD_H_
14 #define CINFERENCEMETHOD_H_
15 
16 #include <shogun/lib/config.h>
17 
18 #ifdef HAVE_EIGEN3
19 
20 #include <shogun/base/SGObject.h>
21 #include <shogun/kernel/Kernel.h>
23 #include <shogun/labels/Labels.h>
27 
28 namespace shogun
29 {
30 
33 {
38  INF_EP=40,
39  INF_KL=50
40 };
41 
52 {
53 public:
56 
65  CInferenceMethod(CKernel* kernel, CFeatures* features,
66  CMeanFunction* mean, CLabels* labels, CLikelihoodModel* model);
67 
68  virtual ~CInferenceMethod();
69 
74  virtual EInferenceType get_inference_type() const { return INF_NONE; }
75 
88 
125  float64_t get_marginal_likelihood_estimate(int32_t num_importance_samples=1,
126  float64_t ridge_size=1e-15);
127 
143  CSGObject*>* parameters);
144 
155  virtual SGVector<float64_t> get_alpha()=0;
156 
168  virtual SGMatrix<float64_t> get_cholesky()=0;
169 
182 
199 
216 
225  CMap<TParameter*, CSGObject*>* parameters)
226  {
228  }
229 
235  {
236  SGVector<float64_t> result(1);
238  return result;
239  }
240 
246 
251  virtual void set_features(CFeatures* feat)
252  {
253  SG_REF(feat);
255  m_features=feat;
256  }
257 
262  virtual CKernel* get_kernel() { SG_REF(m_kernel); return m_kernel; }
263 
268  virtual void set_kernel(CKernel* kern)
269  {
270  SG_REF(kern);
272  m_kernel=kern;
273  }
274 
279  virtual CMeanFunction* get_mean() { SG_REF(m_mean); return m_mean; }
280 
285  virtual void set_mean(CMeanFunction* m)
286  {
287  SG_REF(m);
288  SG_UNREF(m_mean);
289  m_mean=m;
290  }
291 
296  virtual CLabels* get_labels() { SG_REF(m_labels); return m_labels; }
297 
302  virtual void set_labels(CLabels* lab)
303  {
304  SG_REF(lab);
306  m_labels=lab;
307  }
308 
314 
319  virtual void set_model(CLikelihoodModel* mod)
320  {
321  SG_REF(mod);
322  SG_UNREF(m_model);
323  m_model=mod;
324  }
325 
330  virtual float64_t get_scale() const { return m_scale; }
331 
336  virtual void set_scale(float64_t scale) { m_scale=scale; }
337 
343  virtual bool supports_regression() const { return false; }
344 
350  virtual bool supports_binary() const { return false; }
351 
357  virtual bool supports_multiclass() const { return false; }
358 
360  virtual void update();
361 
362 protected:
364  virtual void check_members() const;
365 
367  virtual void update_alpha()=0;
368 
370  virtual void update_chol()=0;
371 
375  virtual void update_deriv()=0;
376 
378  virtual void update_train_kernel();
379 
388  const TParameter* param)=0;
389 
398  const TParameter* param)=0;
399 
408  const TParameter* param)=0;
409 
418  const TParameter* param)=0;
419 
423  static void* get_derivative_helper(void* p);
424 
425 private:
426  void init();
427 
428 protected:
431 
434 
437 
440 
443 
446 
449 
452 
455 };
456 }
457 #endif /* HAVE_EIGEN3 */
458 #endif /* CINFERENCEMETHOD_H_ */

SHOGUN Machine Learning Toolbox - Documentation