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 enum E_SVM_TYPE
00021 {
00022     SVM_OCAS = 0,
00023     SVM_BMRM = 1
00024 };
00025 
00027 class CSVMOcas : public CLinearClassifier
00028 {
00029     public:
00034         CSVMOcas(E_SVM_TYPE type);
00035 
00042         CSVMOcas(
00043             float64_t C, CDotFeatures* traindat,
00044             CLabels* trainlab);
00045         virtual ~CSVMOcas();
00046 
00051         virtual inline EClassifierType get_classifier_type() { return CT_SVMOCAS; }
00052 
00057         virtual bool train();
00058 
00064         inline void set_C(float64_t c1, float64_t c2) { C1=c1; C2=c2; }
00065 
00070         inline float64_t get_C1() { return C1; }
00071 
00076         inline float64_t get_C2() { return C2; }
00077 
00082         inline void set_epsilon(float64_t eps) { epsilon=eps; }
00083 
00088         inline float64_t get_epsilon() { return epsilon; }
00089 
00094         inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
00095 
00100         inline bool get_bias_enabled() { return use_bias; }
00101 
00106         inline void set_bufsize(int32_t sz) { bufsize=sz; }
00107 
00112         inline int32_t get_bufsize() { return bufsize; }
00113 
00114     protected:
00123         static void compute_W(
00124             float64_t *sq_norm_W, float64_t *dp_WoldW, float64_t *alpha,
00125             uint32_t nSel, void* ptr);
00126 
00133         static float64_t update_W(float64_t t, void* ptr );
00134 
00143         static void add_new_cut(
00144             float64_t *new_col_H, uint32_t *new_cut, uint32_t cut_length,
00145             uint32_t nSel, void* ptr );
00146 
00152         static void compute_output( float64_t *output, void* ptr );
00153 
00160         static void sort( float64_t* vals, uint32_t* idx, uint32_t size);
00161 
00163         inline virtual const char* get_name() const { return "SVMOcas"; }
00164 
00165     protected:
00167         bool use_bias;
00169         int32_t bufsize;
00171         float64_t C1;
00173         float64_t C2;
00175         float64_t epsilon;
00177         E_SVM_TYPE method;
00178 
00180         float64_t* old_w;
00182         float64_t old_bias;
00184         float64_t* tmp_a_buf;
00186         float64_t* lab;
00187         
00190         float64_t** cp_value;
00192         uint32_t** cp_index;
00194         uint32_t* cp_nz_dims;
00196         float64_t* cp_bias;
00197 };
00198 #endif

SHOGUN Machine Learning Toolbox - Documentation