MethodSVM.h

Go to the documentation of this file.
00001 // @(#)root/tmva $Id: MethodSVM.h 36966 2010-11-26 09:50:13Z evt $    
00002 // Author: Marcin Wolter, Andrzej Zemla
00003 
00004 /**********************************************************************************
00005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
00006  * Package: TMVA                                                                  *
00007  * Class  : MethodSVM                                                             *
00008  * Web    : http://tmva.sourceforge.net                                           *
00009  *                                                                                *
00010  * Description:                                                                   *
00011  *      Support Vector Machine                                                    *
00012  *                                                                                *
00013  * Authors (alphabetical):                                                        *
00014  *      Marcin Wolter  <Marcin.Wolter@cern.ch> - IFJ PAN, Krakow, Poland          *
00015  *      Andrzej Zemla  <azemla@cern.ch>         - IFJ PAN, Krakow, Poland         *
00016  *      (IFJ PAN: Henryk Niewodniczanski Inst. Nucl. Physics, Krakow, Poland)     *   
00017  *                                                                                *
00018  * Introduction of regression by:                                                 *
00019  *      Krzysztof Danielowski <danielow@cern.ch> - IFJ PAN & AGH, Krakow, Poland  *
00020  *      Kamil Kraszewski      <kalq@cern.ch>     - IFJ PAN & UJ, Krakow, Poland   *
00021  *      Maciej Kruk           <mkruk@cern.ch>    - IFJ PAN & AGH, Krakow, Poland  *
00022  *                                                                                *
00023  * Copyright (c) 2005:                                                            *
00024  *      CERN, Switzerland                                                         * 
00025  *      MPI-K Heidelberg, Germany                                                 * 
00026  *      PAN, Krakow, Poland                                                       *
00027  *                                                                                *
00028  * Redistribution and use in source and binary forms, with or without             *
00029  * modification, are permitted according to the terms listed in LICENSE           *
00030  * (http://tmva.sourceforge.net/LICENSE)                                          *
00031  **********************************************************************************/
00032 
00033 #ifndef ROOT_TMVA_MethodSVM
00034 #define ROOT_TMVA_MethodSVM
00035 
00036 //////////////////////////////////////////////////////////////////////////
00037 //                                                                      //
00038 // MethodSVM                                                            //
00039 //                                                                      //
00040 // SMO Platt's SVM classifier with Keerthi & Shavade improvements       //
00041 //                                                                      //
00042 //////////////////////////////////////////////////////////////////////////
00043 
00044 #ifndef ROOT_TMVA_MethodBase
00045 #include "TMVA/MethodBase.h"
00046 #endif
00047 #ifndef ROOT_TMVA_TMatrixD
00048 #ifndef ROOT_TMatrixDfwd
00049 #include "TMatrixDfwd.h"
00050 #endif
00051 #endif
00052 #ifndef ROOT_TMVA_TVectorD
00053 #ifndef ROOT_TVectorD
00054 #include "TVectorD.h"
00055 #endif
00056 #endif
00057 
00058 namespace TMVA 
00059 {
00060    class SVWorkingSet;
00061    class SVEvent;
00062    class SVKernelFunction;
00063    
00064    class MethodSVM : public MethodBase {
00065 
00066    public:
00067 
00068       MethodSVM( const TString& jobName, const TString& methodTitle, DataSetInfo& theData,
00069                  const TString& theOption = "", TDirectory* theTargetDir = 0 );
00070       
00071       MethodSVM( DataSetInfo& theData, const TString& theWeightFile, TDirectory* theTargetDir = NULL );
00072 
00073       virtual ~MethodSVM( void );
00074     
00075       virtual Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
00076 
00077       // training method
00078       void Train( void );
00079 
00080       using MethodBase::ReadWeightsFromStream;
00081 
00082       // write weights to file
00083       void WriteWeightsToStream( TFile& fout   ) const;
00084       void AddWeightsXMLTo     ( void*  parent ) const;
00085 
00086       // read weights from file
00087       void ReadWeightsFromStream( std::istream& istr );
00088       void ReadWeightsFromStream( TFile& fFin     );
00089       void ReadWeightsFromXML   ( void*  wghtnode );
00090       // calculate the MVA value
00091 
00092       Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 );
00093       const std::vector<Float_t>& GetRegressionValues();
00094       
00095       void Init( void );
00096 
00097       // ranking of input variables
00098       const Ranking* CreateRanking() { return 0; } 
00099 
00100    protected:
00101 
00102       // make ROOT-independent C++ class for classifier response (classifier-specific implementation)
00103       void MakeClassSpecific( std::ostream&, const TString& ) const;
00104 
00105       // get help message text
00106       void GetHelpMessage() const;
00107 
00108    private:
00109 
00110       // the option handling methods
00111       void DeclareOptions();
00112       void DeclareCompatibilityOptions();
00113       void ProcessOptions();
00114       
00115       Float_t                 fCost; // cost value
00116       Float_t                 fTolerance;       // tolerance parameter
00117       UInt_t                  fMaxIter; // max number of iteration
00118       UShort_t                fNSubSets; // nr of subsets, default 1
00119       Float_t                 fBparm;           // free plane coefficient 
00120       Float_t                 fGamma;           // RBF Kernel parameter
00121       SVWorkingSet*           fWgSet;           // svm working set 
00122       std::vector<TMVA::SVEvent*>*  fInputData;       // vector of training data in SVM format
00123       std::vector<TMVA::SVEvent*>*  fSupportVectors; // contains support vectors
00124       SVKernelFunction*       fSVKernelFunction;  // kernel function
00125 
00126       TVectorD*               fMinVars;         // for normalization //is it still needed?? 
00127       TVectorD*               fMaxVars;         // for normalization //is it still needed?? 
00128 
00129       // for backward compatibility
00130       TString     fTheKernel;           // kernel name
00131       Float_t     fDoubleSigmaSquared;  // for RBF Kernel
00132       Int_t       fOrder;               // for Polynomial Kernel ( polynomial order )
00133       Float_t     fTheta;               // for Sigmoidal Kernel
00134       Float_t     fKappa;               // for Sigmoidal Kernel
00135       
00136       ClassDef(MethodSVM,0)  // Support Vector Machine
00137    };
00138 
00139 } // namespace TMVA
00140 
00141 #endif // MethodSVM_H

Generated on Tue Jul 5 14:27:32 2011 for ROOT_528-00b_version by  doxygen 1.5.1