SVMOcas.h

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 2007-2009 Vojtech Franc
00008  * Written (W) 2007-2009 Soeren Sonnenburg
00009  * Copyright (C) 2007-2009 Fraunhofer Institute FIRST and Max-Planck-Society
00010  */
00011 
00012 #ifndef _SVMOCAS_H___
00013 #define _SVMOCAS_H___
00014 
00015 #include "lib/common.h"
00016 #include "classifier/LinearClassifier.h"
00017 #include "features/DotFeatures.h"
00018 #include "features/Labels.h"
00019 
00020 namespace shogun
00021 {
00022 enum E_SVM_TYPE
00023 {
00024     SVM_OCAS = 0,
00025     SVM_BMRM = 1
00026 };
00027 
00029 class CSVMOcas : public CLinearClassifier
00030 {
00031     public:
00036         CSVMOcas(E_SVM_TYPE type);
00037 
00044         CSVMOcas(
00045             float64_t C, CDotFeatures* traindat,
00046             CLabels* trainlab);
00047         virtual ~CSVMOcas();
00048 
00053         virtual inline EClassifierType get_classifier_type() { return CT_SVMOCAS; }
00054 
00063         virtual bool train(CFeatures* data=NULL);
00064 
00070         inline void set_C(float64_t c1, float64_t c2) { C1=c1; C2=c2; }
00071 
00076         inline float64_t get_C1() { return C1; }
00077 
00082         inline float64_t get_C2() { return C2; }
00083 
00088         inline void set_epsilon(float64_t eps) { epsilon=eps; }
00089 
00094         inline float64_t get_epsilon() { return epsilon; }
00095 
00100         inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
00101 
00106         inline bool get_bias_enabled() { return use_bias; }
00107 
00112         inline void set_bufsize(int32_t sz) { bufsize=sz; }
00113 
00118         inline int32_t get_bufsize() { return bufsize; }
00119 
00120     protected:
00129         static void compute_W(
00130             float64_t *sq_norm_W, float64_t *dp_WoldW, float64_t *alpha,
00131             uint32_t nSel, void* ptr);
00132 
00139         static float64_t update_W(float64_t t, void* ptr );
00140 
00149         static void add_new_cut(
00150             float64_t *new_col_H, uint32_t *new_cut, uint32_t cut_length,
00151             uint32_t nSel, void* ptr );
00152 
00158         static void compute_output( float64_t *output, void* ptr );
00159 
00166         static void sort( float64_t* vals, uint32_t* idx, uint32_t size);
00167 
00169         inline virtual const char* get_name() const { return "SVMOcas"; }
00170 
00171     protected:
00173         bool use_bias;
00175         int32_t bufsize;
00177         float64_t C1;
00179         float64_t C2;
00181         float64_t epsilon;
00183         E_SVM_TYPE method;
00184 
00186         float64_t* old_w;
00188         float64_t old_bias;
00190         float64_t* tmp_a_buf;
00192         float64_t* lab;
00193         
00196         float64_t** cp_value;
00198         uint32_t** cp_index;
00200         uint32_t* cp_nz_dims;
00202         float64_t* cp_bias;
00203 };
00204 }
00205 #endif

SHOGUN Machine Learning Toolbox - Documentation