Machine Learning Library
COneClassSVM.h
Go to the documentation of this file.
1 /*
2  COPYRIGHT (C) 2003 APPLIED NEUROINFORMATIC GROUP - UNIVERSITY OF BIELEFELD.
3 
4  ALL RIGHTS RESERVED.
5 
6  REDISTRIBUTION AND USE IN SOURCE AND BINARY FORM, WITH OR WITHOUT
7  MODIFICATION, REQUIRE THE PERMISSION OF THE COPYRIGHT HOLDERS.
8 
9  COMMERCIAL USE WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT HOLDERS
10  IS FORBIDDEN
11 
12  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
13  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15  ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
16  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
18  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
19  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
20  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
21  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 */
23 
24 
25 
26 #ifndef CONECLASSSVM_H
27 #define CONECLASSSVM_H
28 
29 #include "CClassifier.h"
30 #include "CKernel.h"
31 #include "CSVM.h"
32 #include "CDataset.h"
33 #include "CVector.h"
34 #include <vector>
35 
42 template<class Type>
43 class COneClassSVM : public CClassifier<Type>
44 {
45 protected:
46  double tNu;
47  double tRho;
48  double tKKTEpsilon;
49  double tBound;
51 
54  vector<CSVCandidate<Type> > tWorkingSet;
55 
56 
57 public:
58  COneClassSVM(CKernel<Type>* ptKernel = new CGaussianKernel<Type>(), int iCacheSize = 100);
59  ~COneClassSVM();
60 
61  int classify(const CVector<Type>& tPattern) const;
62  int classify(Type* ptPattern, Type& rtConfidence) const;
63  void classify(Type* ptPattern, Type& rtClass, Type& rtConfidence) const;
64  void classify(const CVector<Type>& rtPattern, Type& rtClass, Type& rtConfidence) const;
65  void init(const CDataset<Type>& tTrainSet);
66  void train(const CDataset<Type>& tTrainSet);
69  const CKernel<Type>* kernel() {
70  return ptKernel;
71  };
72 
76  void setCacheSize (Type tSize) {
77  ptCache->setCacheSize(tSize);
78  };
79 
80 
81  void setRegularization(Type tNu) { this->tNu = tNu;};
82  void setEpsilon(Type tEpsilon) { tKKTEpsilon = tEpsilon;};
83 protected:
84  int takeStep(int a, int b);
85  int examineExample(int i);
86  int findBestPartner(int iIndex);
87  bool checkKKT(int iIndex);
88  Type calculateOutput(int iIndex);
89 
90 };
91 
92 #endif
int classify(const CVector< Type > &tPattern) const
void setEpsilon(Type tEpsilon)
Definition: COneClassSVM.h:82
int iNumIteration
Definition: COneClassSVM.h:50
double tBound
Definition: COneClassSVM.h:49
double tRho
Definition: COneClassSVM.h:47
CDataset< Type > getSupportData()
OneClass SVM algorithm for estimating the support of a data distribution.
Definition: COneClassSVM.h:43
int findBestPartner(int iIndex)
COneClassSVM(CKernel< Type > *ptKernel=new CGaussianKernel< Type >(), int iCacheSize=100)
void setCacheSize(Type tSize)
Definition: COneClassSVM.h:76
int takeStep(int a, int b)
Definition: CKernelCache.h:39
void train(const CDataset< Type > &tTrainSet)
CKernelCache< Type > * ptCache
Definition: COneClassSVM.h:53
vector< CSVCandidate< Type > > tWorkingSet
Definition: COneClassSVM.h:54
Base class for kernel functions Base class for kernel function used for example by the support vector...
Definition: CKernel.h:46
Gaussian kernel function.
Definition: CKernel.h:79
double tKKTEpsilon
Definition: COneClassSVM.h:48
templatized vector for numerical applications
Definition: CMatrix.h:39
Manages pairs of input and output vectors.
Definition: CDataset.h:110
double tNu
Definition: COneClassSVM.h:46
void setRegularization(Type tNu)
Definition: COneClassSVM.h:81
bool checkKKT(int iIndex)
CKernel< Type > * ptKernel
Definition: COneClassSVM.h:52
void init(const CDataset< Type > &tTrainSet)
int examineExample(int i)
const CKernel< Type > * kernel()
Definition: COneClassSVM.h:69
Type calculateOutput(int iIndex)
void setKernel(CKernel< Type > *ptKernel)