Classifier.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 _CLASSIFIER_H__
00012 #define _CLASSIFIER_H__
00013 
00014 #include "lib/common.h"
00015 #include "base/SGObject.h"
00016 #include "lib/Mathematics.h"
00017 #include "features/Labels.h"
00018 
00019 
00020 enum EClassifierType
00021 {
00022     CT_NONE = 0,
00023     CT_LIGHT = 10,
00024     CT_LIBSVM = 20,
00025     CT_LIBSVMONECLASS=30,
00026     CT_LIBSVMMULTICLASS=40,
00027     CT_MPD = 50,
00028     CT_GPBT = 60,
00029     CT_CPLEXSVM = 70,
00030     CT_PERCEPTRON = 80,
00031     CT_KERNELPERCEPTRON = 90,
00032     CT_LDA = 100,
00033     CT_LPM = 110,
00034     CT_LPBOOST = 120,
00035     CT_KNN = 130,
00036     CT_SVMLIN=140,
00037     CT_KRR = 150,
00038     CT_GNPPSVM = 160,
00039     CT_GMNPSVM = 170,
00040     CT_SUBGRADIENTSVM = 180,
00041     CT_SUBGRADIENTLPM = 190,
00042     CT_SVMPERF = 200,
00043     CT_LIBSVR = 210,
00044     CT_SVRLIGHT = 220,
00045     CT_LIBLINEAR = 230,
00046     CT_KMEANS = 240,
00047     CT_HIERARCHICAL = 250,
00048     CT_SVMOCAS = 260,
00049     CT_WDSVMOCAS = 270,
00050     CT_SVMSGD = 280,
00051     CT_GMNPMKL=290
00052 };
00053 
00054 enum ESolverType
00055 {
00056     ST_AUTO=0,
00057     ST_CPLEX=1,
00058     ST_GLPK=2,
00059     ST_INTERNAL=3
00060 };
00061 
00073 class CClassifier : public CSGObject
00074 {
00075     public:
00077         CClassifier();
00078         virtual ~CClassifier();
00079 
00084         virtual bool train() { return false; }
00085 
00091         virtual CLabels* classify(CLabels* output=NULL);
00092 
00100         virtual float64_t classify_example(int32_t num) { return CMath::INFTY; }
00101 
00109         virtual bool load(FILE* srcfile) { ASSERT(srcfile); return false; }
00110 
00118         virtual bool save(FILE* dstfile) { ASSERT(dstfile); return false; }
00119 
00124         virtual inline void set_labels(CLabels* lab)
00125         {
00126             SG_UNREF(labels);
00127             SG_REF(lab);
00128             labels=lab;
00129         }
00130 
00135         virtual inline CLabels* get_labels() { SG_REF(labels); return labels; }
00136 
00142         virtual inline float64_t get_label(int32_t i) { return labels->get_label(i); }
00143 
00148         inline void set_max_train_time(float64_t t) { max_train_time=t; }
00149 
00154         inline float64_t get_max_train_time() { return max_train_time; }
00155 
00160         virtual inline EClassifierType get_classifier_type() { return CT_NONE; }
00161 
00166         inline void set_solver_type(ESolverType st) { solver_type=st; }
00167 
00172         inline ESolverType get_solver_type() { return solver_type; }
00173 
00174     protected:
00176         float64_t max_train_time;
00177 
00179         CLabels* labels;
00180 
00182         ESolverType solver_type;
00183 };
00184 
00185 #endif // _CLASSIFIER_H__

SHOGUN Machine Learning Toolbox - Documentation