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 
00071         inline void set_C(float64_t c_neg, float64_t c_pos) { C1=c_neg; C2=c_pos; }
00072 
00077         inline float64_t get_C1() { return C1; }
00078 
00083         inline float64_t get_C2() { return C2; }
00084 
00089         inline void set_epsilon(float64_t eps) { epsilon=eps; }
00090 
00095         inline float64_t get_epsilon() { return epsilon; }
00096 
00101         inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
00102 
00107         inline bool get_bias_enabled() { return use_bias; }
00108 
00113         inline void set_bufsize(int32_t sz) { bufsize=sz; }
00114 
00119         inline int32_t get_bufsize() { return bufsize; }
00120 
00121     protected:
00130         static void compute_W(
00131             float64_t *sq_norm_W, float64_t *dp_WoldW, float64_t *alpha,
00132             uint32_t nSel, void* ptr);
00133 
00140         static float64_t update_W(float64_t t, void* ptr );
00141 
00150         static void add_new_cut(
00151             float64_t *new_col_H, uint32_t *new_cut, uint32_t cut_length,
00152             uint32_t nSel, void* ptr );
00153 
00159         static void compute_output( float64_t *output, void* ptr );
00160 
00167         static void sort( float64_t* vals, uint32_t* idx, uint32_t size);
00168 
00170         inline virtual const char* get_name() const { return "SVMOcas"; }
00171 
00172     protected:
00174         bool use_bias;
00176         int32_t bufsize;
00178         float64_t C1;
00180         float64_t C2;
00182         float64_t epsilon;
00184         E_SVM_TYPE method;
00185 
00187         float64_t* old_w;
00189         float64_t old_bias;
00191         float64_t* tmp_a_buf;
00193         float64_t* lab;
00194 
00197         float64_t** cp_value;
00199         uint32_t** cp_index;
00201         uint32_t* cp_nz_dims;
00203         float64_t* cp_bias;
00204 };
00205 }
00206 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation