LibLinear.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-2008 Soeren Sonnenburg
00008  * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society
00009  */
00010 
00011 #ifndef _LIBLINEAR_H___
00012 #define _LIBLINEAR_H___
00013 
00014 #include "lib/config.h"
00015 
00016 #ifdef HAVE_LAPACK
00017 #include "lib/common.h"
00018 #include "classifier/SparseLinearClassifier.h"
00019 
00020 enum LIBLINEAR_LOSS
00021 {
00022     LR = 0,
00023     L2 = 1
00024 };
00025 
00027 class CLibLinear : public CSparseLinearClassifier
00028 {
00029     public:
00034         CLibLinear(LIBLINEAR_LOSS loss);
00035 
00042         CLibLinear(DREAL C, CSparseFeatures<DREAL>* traindat, CLabels* trainlab);
00043 
00044         virtual ~CLibLinear();
00045 
00047         virtual bool train();
00048 
00053         virtual inline EClassifierType get_classifier_type() { return CT_LIBLINEAR; }
00054 
00060         inline void set_C(DREAL c1, DREAL c2) { C1=c1; C2=c2; }
00061 
00066         inline DREAL get_C1() { return C1; }
00067 
00072         inline DREAL get_C2() { return C2; }
00073 
00078         inline void set_epsilon(DREAL eps) { epsilon=eps; }
00079 
00084         inline DREAL get_epsilon() { return epsilon; }
00085 
00090         inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
00091 
00096         inline bool get_bias_enabled() { return use_bias; }
00097 
00098     protected:
00100         DREAL C1;
00102         DREAL C2;
00104         bool use_bias;
00106         DREAL epsilon;
00107 
00109         LIBLINEAR_LOSS loss;
00110 };
00111 #endif //HAVE_LAPACK
00112 #endif //_LIBLINEAR_H___

SHOGUN Machine Learning Toolbox - Documentation