MethodLD.h

Go to the documentation of this file.
00001 // Author: Krzysztof Danielowski, Kamil Kraszewski, Maciej Kruk, Jan Therhaag 
00002 
00003 /**********************************************************************************
00004  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
00005  * Package: TMVA                                                                  *
00006  * Class  : MethodLD                                                              *
00007  * Web    : http://tmva.sourceforge.net                                           *
00008  *                                                                                *
00009  * Description:                                                                   *
00010  *      Linear Discriminant (Simple Linear Regression)                            *
00011  *                                                                                *
00012  * Authors (alphabetical):                                                        *
00013  *      Krzysztof Danielowski <danielow@cern.ch> - IFJ PAN & AGH, Poland          *
00014  *      Kamil Kraszewski      <kalq@cern.ch>     - IFJ PAN & UJ, Poland           *
00015  *      Maciej Kruk           <mkruk@cern.ch>    - IFJ PAN & AGH, Poland          *
00016  *      Peter Speckmayer      <peter.speckmayer@cern.ch>  - CERN, Switzerland     *
00017  *      Jan Therhaag          <therhaag@physik.uni-bonn.de> - Uni Bonn, Germany   *
00018  *                                                                                *
00019  * Copyright (c) 2008:                                                            *
00020  *      CERN, Switzerland                                                         * 
00021  *      PAN, Poland                                                               * 
00022  *                                                                                *
00023  * Redistribution and use in source and binary forms, with or without             *
00024  * modification, are permitted according to the terms listed in LICENSE           *
00025  * (http://tmva.sourceforge.net/LICENSE)                                          *
00026  *                                                                                *
00027  **********************************************************************************/
00028 
00029 #ifndef ROOT_TMVA_MethodLD
00030 #define ROOT_TMVA_MethodLD
00031 
00032 //////////////////////////////////////////////////////////////////////////
00033 //                                                                      //
00034 // MethodLD                                                             //
00035 //                                                                      //
00036 // Linear Discriminant                                                  //
00037 // Can compute multidimensional output for regression                   //
00038 // (although it computes every dimension separately)                    //
00039 //                                                                      //
00040 //////////////////////////////////////////////////////////////////////////
00041 
00042 #include <vector>
00043 
00044 #ifndef ROOT_TMVA_MethodBase
00045 #include "TMVA/MethodBase.h"
00046 #endif
00047 #ifndef ROOT_TMatrixDfwd
00048 #include "TMatrixDfwd.h"
00049 #endif
00050 
00051 namespace TMVA {
00052 
00053    class MethodLD : public MethodBase {
00054 
00055    public:
00056    
00057       // constructor
00058       MethodLD( const TString& jobName, 
00059                 const TString& methodTitle, 
00060                 DataSetInfo& dsi,
00061                 const TString& theOption = "LD",
00062                 TDirectory* theTargetDir = 0 );
00063       
00064       // constructor
00065       MethodLD( DataSetInfo& dsi, 
00066                 const TString& theWeightFile, 
00067                 TDirectory* theTargetDir = 0 );
00068 
00069       // destructor
00070       virtual ~MethodLD( void );
00071 
00072       Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
00073     
00074       // training method
00075       void Train( void );
00076 
00077       // calculate the MVA value
00078       Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 );
00079 
00080       // calculate the Regression value
00081       virtual const std::vector<Float_t>& GetRegressionValues();
00082 
00083       using MethodBase::ReadWeightsFromStream;   
00084 
00085       void AddWeightsXMLTo      ( void* parent ) const;
00086 
00087       void ReadWeightsFromStream( std::istream & i );
00088       void ReadWeightsFromXML   ( void* wghtnode );
00089 
00090       const Ranking* CreateRanking();
00091       void DeclareOptions();
00092       void ProcessOptions();
00093 
00094    protected:
00095 
00096       void MakeClassSpecific( std::ostream&, const TString& ) const;
00097       void GetHelpMessage() const;
00098 
00099    private:
00100 
00101       Int_t fNRegOut; // size of the output
00102  
00103       TMatrixD *fSumMatx;              // Sum of coordinates product matrix 
00104       TMatrixD *fSumValMatx;           // Sum of values multiplied by coordinates
00105       TMatrixD *fCoeffMatx;            // Matrix of coefficients
00106       std::vector< std::vector<Double_t>* > *fLDCoeff; // LD coefficients
00107 
00108       // default initialisation called by all constructors
00109       void Init( void );
00110 
00111       // Initialization and allocation of matrices
00112       void InitMatrices( void );
00113 
00114       // Compute fSumMatx
00115       void GetSum( void );
00116 
00117       // Compute fSumValMatx
00118       void GetSumVal( void );
00119 
00120       // get LD coefficients
00121       void GetLDCoeff( void );
00122       
00123       // nice output
00124       void PrintCoefficients( void );
00125 
00126       ClassDef(MethodLD,0) //Linear discriminant analysis
00127          };
00128 } // namespace TMVA
00129 
00130 #endif // MethodLD_H

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