SVRLight.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/SVMLight.h"
00019 #endif //USE_SVMLIGHT
00020 
00021 #ifdef USE_SVMLIGHT
00022 namespace shogun
00023 {
00062 #define IGNORE_IN_CLASSLIST
00063 IGNORE_IN_CLASSLIST class CSVRLight: public CSVMLight
00064 {
00065     public:
00067         CSVRLight();
00068 
00076         CSVRLight(float64_t C, float64_t epsilon, CKernel* k, CLabels* lab);
00077 
00079         virtual ~CSVRLight() { }
00080 
00089         virtual bool train(CFeatures* data=NULL);
00090 
00095         virtual inline EClassifierType get_classifier_type() { return CT_SVRLIGHT; }
00096 
00098         void   svr_learn();
00099 
00109         virtual float64_t compute_objective_function(
00110             float64_t *a, float64_t *lin, float64_t *c, float64_t* eps,
00111             int32_t *label, int32_t totdoc);
00112 
00126         virtual void update_linear_component(
00127             int32_t* docs, int32_t *label,
00128             int32_t *active2dnum, float64_t *a, float64_t* a_old,
00129             int32_t *working2dnum, int32_t totdoc,
00130             float64_t *lin, float64_t *aicache, float64_t* c);
00131 
00145         virtual void update_linear_component_mkl(
00146             int32_t* docs, int32_t *label,
00147             int32_t *active2dnum, float64_t *a, float64_t* a_old,
00148             int32_t *working2dnum, int32_t totdoc,
00149             float64_t *lin, float64_t *aicache, float64_t* c);
00150 
00164         virtual void update_linear_component_mkl_linadd(
00165             int32_t* docs, int32_t *label,
00166             int32_t *active2dnum, float64_t *a, float64_t* a_old,
00167             int32_t *working2dnum, int32_t totdoc,
00168             float64_t *lin, float64_t *aicache, float64_t* c);
00169 
00170         void call_mkl_callback(float64_t* a, int32_t* label, float64_t* lin, float64_t* c, int32_t totdoc);
00171 
00186         virtual void reactivate_inactive_examples(
00187             int32_t *label,float64_t *a,SHRINK_STATE *shrink_state,
00188             float64_t *lin, float64_t *c, int32_t totdoc,int32_t iteration,
00189             int32_t *inconsistent,
00190             int32_t *docs,float64_t *aicache,
00191             float64_t* maxdiff);
00192 
00194         inline virtual const char* get_name() const { return "SVRLight"; }
00195 
00196     protected:
00201         static void* update_linear_component_linadd_helper(void *params);
00202 
00208         inline int32_t regression_fix_index(int32_t i)
00209         {
00210             if (i>=num_vectors)
00211                 i=2*num_vectors-1-i;
00212 
00213             return i;
00214         }
00215 
00222         static inline int32_t regression_fix_index2(
00223             int32_t i, int32_t num_vectors)
00224         {
00225             if (i>=num_vectors)
00226                 i=2*num_vectors-1-i;
00227 
00228             return i;
00229         }
00230 
00237         inline virtual float64_t compute_kernel(int32_t i, int32_t j)
00238         {
00239             i=regression_fix_index(i);
00240             j=regression_fix_index(j);
00241             return kernel->kernel(i, j);
00242         }
00243 
00245         int32_t num_vectors;
00246 };
00247 }
00248 #endif //USE_SVMLIGHT
00249 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation