SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MPDSVM.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) 1999-2009 Soeren Sonnenburg
8  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  */
10 
11 #ifndef _MPDSVM_H___
12 #define _MPDSVM_H___
13 
14 #include <shogun/lib/config.h>
15 
16 #include <shogun/lib/common.h>
18 #include <shogun/lib/Cache.h>
20 
21 namespace shogun
22 {
24 class CMPDSVM : public CSVM
25 {
26  public:
28  CMPDSVM();
29 
36  CMPDSVM(float64_t C, CKernel* k, CLabels* lab);
37  virtual ~CMPDSVM();
38 
43  virtual EMachineType get_classifier_type() { return CT_MPD; }
44 
46  virtual const char* get_name() const { return "MPDSVM"; }
47 
48  protected:
57  virtual bool train_machine(CFeatures* data=NULL);
58 
65  inline float64_t compute_H(int32_t i, int32_t j)
66  {
67  return ((CBinaryLabels*) m_labels)->get_label(i)*
68  ((CBinaryLabels*) m_labels)->get_label(j)*kernel->kernel(i,j);
69  }
70 
76  inline KERNELCACHE_ELEM* lock_kernel_row(int32_t i)
77  {
78  KERNELCACHE_ELEM* line=NULL;
79 
80  if (kernel_cache->is_cached(i))
81  {
82  line=kernel_cache->lock_entry(i);
83  ASSERT(line)
84  }
85 
86  if (!line)
87  {
88  line=kernel_cache->set_entry(i);
89  ASSERT(line)
90 
91  for (int32_t j=0; j<m_labels->get_num_labels(); j++)
92  line[j]=(KERNELCACHE_ELEM) ((CBinaryLabels*) m_labels)->get_label(i)*((CBinaryLabels*) m_labels)->get_label(j)*kernel->kernel(i,j);
93  }
94 
95  return line;
96  }
97 
102  inline void unlock_kernel_row(int32_t i)
103  {
105  }
106 
109 };
110 }
111 #endif /* _MPDSVM_H___ */

SHOGUN Machine Learning Toolbox - Documentation