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 <shogun/lib/common.h>
00016 #include <shogun/machine/LinearMachine.h>
00017 #include <shogun/classifier/svm/libocas.h>
00018 #include <shogun/features/DotFeatures.h>
00019 #include <shogun/features/Labels.h>
00020 
00021 namespace shogun
00022 {
00023 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00024 enum E_SVM_TYPE
00025 {
00026     SVM_OCAS = 0,
00027     SVM_BMRM = 1
00028 };
00029 #endif
00030 
00032 class CSVMOcas : public CLinearMachine
00033 {
00034     public:
00036         CSVMOcas(void);
00037 
00042         CSVMOcas(E_SVM_TYPE type);
00043 
00050         CSVMOcas(
00051             float64_t C, CDotFeatures* traindat,
00052             CLabels* trainlab);
00053         virtual ~CSVMOcas();
00054 
00059         virtual inline EClassifierType get_classifier_type() { return CT_SVMOCAS; }
00060 
00067         inline void set_C(float64_t c_neg, float64_t c_pos) { C1=c_neg; C2=c_pos; }
00068 
00073         inline float64_t get_C1() { return C1; }
00074 
00079         inline float64_t get_C2() { return C2; }
00080 
00085         inline void set_epsilon(float64_t eps) { epsilon=eps; }
00086 
00091         inline float64_t get_epsilon() { return epsilon; }
00092 
00097         inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
00098 
00103         inline bool get_bias_enabled() { return use_bias; }
00104 
00109         inline void set_bufsize(int32_t sz) { bufsize=sz; }
00110 
00115         inline int32_t get_bufsize() { return bufsize; }
00116 
00117     protected:
00126         static void compute_W(
00127             float64_t *sq_norm_W, float64_t *dp_WoldW, float64_t *alpha,
00128             uint32_t nSel, void* ptr);
00129 
00136         static float64_t update_W(float64_t t, void* ptr );
00137 
00146         static int add_new_cut(
00147             float64_t *new_col_H, uint32_t *new_cut, uint32_t cut_length,
00148             uint32_t nSel, void* ptr );
00149 
00155         static int compute_output( float64_t *output, void* ptr );
00156 
00163         static int sort( float64_t* vals, float64_t* data, uint32_t size);
00164 
00166         static inline void print(ocas_return_value_T value)
00167         {
00168               return;
00169         }
00170 
00171     protected:
00180         virtual bool train_machine(CFeatures* data=NULL);
00181 
00183         inline virtual const char* get_name() const { return "SVMOcas"; }
00184     private:
00185         void init();
00186 
00187     protected:
00189         bool use_bias;
00191         int32_t bufsize;
00193         float64_t C1;
00195         float64_t C2;
00197         float64_t epsilon;
00199         E_SVM_TYPE method;
00200 
00202         float64_t* old_w;
00204         float64_t old_bias;
00206         float64_t* tmp_a_buf;
00208         SGVector<float64_t> lab;
00209 
00212         float64_t** cp_value;
00214         uint32_t** cp_index;
00216         uint32_t* cp_nz_dims;
00218         float64_t* cp_bias;
00219 };
00220 }
00221 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation