SHOGUN  4.1.0
 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 {
42  INF_EP=40,
43  INF_KL=50,
48 };
49 
60 {
61 public:
64 
73  CInferenceMethod(CKernel* kernel, CFeatures* features,
74  CMeanFunction* mean, CLabels* labels, CLikelihoodModel* model);
75 
76  virtual ~CInferenceMethod();
77 
82  virtual EInferenceType get_inference_type() const { return INF_NONE; }
83 
96 
133  float64_t get_marginal_likelihood_estimate(int32_t num_importance_samples=1,
134  float64_t ridge_size=1e-15);
135 
151  CSGObject*>* parameters);
152 
166  virtual SGVector<float64_t> get_alpha()=0;
167 
173  virtual SGMatrix<float64_t> get_cholesky()=0;
174 
180  virtual SGVector<float64_t> get_diagonal_vector()=0;
181 
198 
215 
224  CMap<TParameter*, CSGObject*>* parameters)
225  {
227  }
228 
234  {
235  SGVector<float64_t> result(1);
237  return result;
238  }
239 
245 
250  virtual void set_features(CFeatures* feat)
251  {
252  SG_REF(feat);
254  m_features=feat;
255  }
256 
261  virtual CKernel* get_kernel() { SG_REF(m_kernel); return m_kernel; }
262 
267  virtual void set_kernel(CKernel* kern)
268  {
269  SG_REF(kern);
271  m_kernel=kern;
272  }
273 
278  virtual CMeanFunction* get_mean() { SG_REF(m_mean); return m_mean; }
279 
284  virtual void set_mean(CMeanFunction* m)
285  {
286  SG_REF(m);
287  SG_UNREF(m_mean);
288  m_mean=m;
289  }
290 
295  virtual CLabels* get_labels() { SG_REF(m_labels); return m_labels; }
296 
301  virtual void set_labels(CLabels* lab)
302  {
303  SG_REF(lab);
305  m_labels=lab;
306  }
307 
313 
318  virtual void set_model(CLikelihoodModel* mod)
319  {
320  SG_REF(mod);
321  SG_UNREF(m_model);
322  m_model=mod;
323  }
324 
329  virtual float64_t get_scale() const { return m_scale; }
330 
335  virtual void set_scale(float64_t scale) { m_scale=scale; }
336 
342  virtual bool supports_regression() const { return false; }
343 
349  virtual bool supports_binary() const { return false; }
350 
356  virtual bool supports_multiclass() const { return false; }
357 
359  virtual void update();
360 
367 
368 protected:
370  virtual void check_members() const;
371 
373  virtual void update_alpha()=0;
374 
376  virtual void update_chol()=0;
377 
381  virtual void update_deriv()=0;
382 
384  virtual void update_train_kernel();
385 
394  const TParameter* param)=0;
395 
404  const TParameter* param)=0;
405 
414  const TParameter* param)=0;
415 
424  const TParameter* param)=0;
425 
429  static void* get_derivative_helper(void* p);
430 
431 private:
432  void init();
433 
434 protected:
437 
440 
443 
446 
449 
452 
455 
458 
461 
464 };
465 }
466 #endif /* HAVE_EIGEN3 */
467 #endif /* CINFERENCEMETHOD_H_ */

SHOGUN Machine Learning Toolbox - Documentation