SHOGUN  v3.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MKLMulticlass.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) 2009 Alexander Binder
00008  * Copyright (C) 2009 Fraunhofer Institute FIRST and Max-Planck-Society
00009  *
00010  * Update to patch 0.10.0 - thanks to Eric aka Yoo (thereisnoknife@gmail.com)
00011  *
00012  */
00013 
00014 #ifndef MKLMulticlass_H_
00015 #define MKLMulticlass_H_
00016 
00017 #include <vector>
00018 
00019 #include <shogun/base/SGObject.h>
00020 #include <shogun/kernel/Kernel.h>
00021 #include <shogun/kernel/CombinedKernel.h>
00022 #include <shogun/multiclass/GMNPSVM.h>
00023 #include <shogun/classifier/mkl/MKLMulticlassGLPK.h>
00024 #include <shogun/classifier/mkl/MKLMulticlassGradient.h>
00025 #include <shogun/multiclass/MulticlassSVM.h>
00026 
00027 
00028 namespace shogun
00029 {
00030 
00041 class CMKLMulticlass : public CMulticlassSVM
00042 {
00043 public:
00045    CMKLMulticlass();
00046 
00052    CMKLMulticlass(float64_t C, CKernel* k, CLabels* lab);
00053 
00055    virtual ~CMKLMulticlass();
00056 
00061    virtual inline EMachineType get_classifier_type()
00062    { return CT_MKLMULTICLASS; }
00063 
00072    float64_t* getsubkernelweights(int32_t & numweights);
00073 
00081    void set_mkl_epsilon(float64_t eps );
00082 
00090    void set_max_num_mkliters(int32_t maxnum);
00091 
00095    virtual void set_mkl_norm(float64_t norm);
00096 
00097 protected:
00102    CMKLMulticlass( const CMKLMulticlass & cm);
00103 
00108    CMKLMulticlass operator=( const CMKLMulticlass & cm);
00109 
00114    void initlpsolver();
00115 
00119    void initsvm();
00120 
00121 
00127    virtual bool evaluatefinishcriterion(const int32_t
00128          numberofsilpiterations);
00129 
00130 
00140    void addingweightsstep( const std::vector<float64_t> & curweights);
00141 
00146    float64_t getsumofsignfreealphas();
00147 
00154    float64_t getsquarenormofprimalcoefficients(
00155          const int32_t ind);
00156 
00165    virtual bool train_machine(CFeatures* data=NULL);
00166 
00168     virtual const char* get_name() const { return "MKLMulticlass"; }
00169 
00170 protected:
00175    CGMNPSVM* svm;
00176 
00178    MKLMulticlassOptimizationBase* lpw;
00179 
00181    ::std::vector< std::vector< float64_t> > weightshistory;
00182 
00186    float64_t mkl_eps;
00187 
00191    int32_t max_num_mkl_iters;
00192 
00196    float64_t pnorm;
00197 
00202    std::vector<float64_t> normweightssquared;
00203 
00205    std::vector<float64_t> oldnormweightssquared;
00206 
00208    float64_t curalphaterm;
00210    float64_t oldalphaterm;
00211 };
00212 
00213 }
00214 #endif // GMNPMKL_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation