SVMOcas.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef _SVMOCAS_H___
00013 #define _SVMOCAS_H___
00014
00015 #include "lib/common.h"
00016 #include "classifier/SparseLinearClassifier.h"
00017 #include "features/SparseFeatures.h"
00018 #include "features/Labels.h"
00019
00020 enum E_SVM_TYPE
00021 {
00022 SVM_OCAS = 0,
00023 SVM_BMRM = 1
00024 };
00025
00027 class CSVMOcas : public CSparseLinearClassifier
00028 {
00029 public:
00034 CSVMOcas(E_SVM_TYPE type);
00035
00042 CSVMOcas(DREAL C, CSparseFeatures<DREAL>* traindat, CLabels* trainlab);
00043 virtual ~CSVMOcas();
00044
00049 virtual inline EClassifierType get_classifier_type() { return CT_SVMOCAS; }
00050
00055 virtual bool train();
00056
00062 inline void set_C(DREAL c1, DREAL c2) { C1=c1; C2=c2; }
00063
00068 inline DREAL get_C1() { return C1; }
00069
00074 inline DREAL get_C2() { return C2; }
00075
00080 inline void set_epsilon(DREAL eps) { epsilon=eps; }
00081
00086 inline DREAL get_epsilon() { return epsilon; }
00087
00092 inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
00093
00098 inline bool get_bias_enabled() { return use_bias; }
00099
00104 inline void set_bufsize(INT sz) { bufsize=sz; }
00105
00110 inline INT get_bufsize() { return bufsize; }
00111
00112 protected:
00121 static void compute_W( double *sq_norm_W, double *dp_WoldW, double *alpha, uint32_t nSel, void* ptr );
00122
00129 static double update_W(double t, void* ptr );
00130
00139 static void add_new_cut( double *new_col_H, uint32_t *new_cut, uint32_t cut_length, uint32_t nSel, void* ptr );
00140
00146 static void compute_output( double *output, void* ptr );
00147
00154 static void sort( double* vals, uint32_t* idx, uint32_t size);
00155
00156
00157 protected:
00159 bool use_bias;
00161 INT bufsize;
00163 DREAL C1;
00165 DREAL C2;
00167 DREAL epsilon;
00169 E_SVM_TYPE method;
00170
00172 DREAL* old_w;
00174 DREAL* tmp_a_buf;
00176 DREAL* lab;
00177
00180 DREAL** cp_value;
00182 uint32_t** cp_index;
00184 uint32_t* cp_nz_dims;
00185
00186 };
00187 #endif