SHOGUN v0.9.3
SVR_light.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) 1999-2009 Soeren Sonnenburg
00008  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
00009  */
00010 
00011 #ifndef _SVRLight_H___
00012 #define _SVRLight_H___
00013 
00014 #include "lib/config.h"
00015 #include "regression/Regression.h"
00016 
00017 #ifdef USE_SVMLIGHT
00018 #include "classifier/svm/SVM_light.h"
00019 #endif //USE_SVMLIGHT
00020 
00021 #ifdef USE_SVMLIGHT
00022 namespace shogun
00023 {
00062 class CSVRLight: public CSVMLight
00063 {
00064     public:
00066         CSVRLight();
00067 
00075         CSVRLight(float64_t C, float64_t epsilon, CKernel* k, CLabels* lab);
00076 
00078         virtual ~CSVRLight() { }
00079 
00088         virtual bool train(CFeatures* data=NULL);
00089 
00094         virtual inline EClassifierType get_classifier_type() { return CT_SVRLIGHT; }
00095 
00097         void   svr_learn();
00098 
00108         virtual float64_t compute_objective_function(
00109             float64_t *a, float64_t *lin, float64_t *c, float64_t* eps,
00110             int32_t *label, int32_t totdoc);
00111 
00125         virtual void update_linear_component(
00126             int32_t* docs, int32_t *label,
00127             int32_t *active2dnum, float64_t *a, float64_t* a_old,
00128             int32_t *working2dnum, int32_t totdoc,
00129             float64_t *lin, float64_t *aicache, float64_t* c);
00130 
00144         virtual void update_linear_component_mkl(
00145             int32_t* docs, int32_t *label,
00146             int32_t *active2dnum, float64_t *a, float64_t* a_old,
00147             int32_t *working2dnum, int32_t totdoc,
00148             float64_t *lin, float64_t *aicache, float64_t* c);
00149 
00163         virtual void update_linear_component_mkl_linadd(
00164             int32_t* docs, int32_t *label,
00165             int32_t *active2dnum, float64_t *a, float64_t* a_old,
00166             int32_t *working2dnum, int32_t totdoc,
00167             float64_t *lin, float64_t *aicache, float64_t* c);
00168 
00169         void call_mkl_callback(float64_t* a, int32_t* label, float64_t* lin, float64_t* c, int32_t totdoc);
00170 
00185         virtual void reactivate_inactive_examples(
00186             int32_t *label,float64_t *a,SHRINK_STATE *shrink_state,
00187             float64_t *lin, float64_t *c, int32_t totdoc,int32_t iteration,
00188             int32_t *inconsistent,
00189             int32_t *docs,float64_t *aicache,
00190             float64_t* maxdiff);
00191 
00193         inline virtual const char* get_name() const { return "SVR_light"; }
00194 
00195     protected:
00200         static void* update_linear_component_linadd_helper(void *params);
00201 
00207         inline int32_t regression_fix_index(int32_t i)
00208         {
00209             if (i>=num_vectors)
00210                 i=2*num_vectors-1-i;
00211 
00212             return i;
00213         }
00214 
00221         static inline int32_t regression_fix_index2(
00222             int32_t i, int32_t num_vectors)
00223         {
00224             if (i>=num_vectors)
00225                 i=2*num_vectors-1-i;
00226 
00227             return i;
00228         }
00229 
00236         inline virtual float64_t compute_kernel(int32_t i, int32_t j)
00237         {
00238             i=regression_fix_index(i);
00239             j=regression_fix_index(j);
00240             return kernel->kernel(i, j);
00241         }
00242 
00244         int32_t num_vectors;
00245 };
00246 }
00247 #endif //USE_SVMLIGHT
00248 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation