MethodLikelihood.h

Go to the documentation of this file.
00001 // @(#)root/tmva $Id: MethodLikelihood.h 36966 2010-11-26 09:50:13Z evt $ 
00002 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss 
00003 
00004 /**********************************************************************************
00005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
00006  * Package: TMVA                                                                  *
00007  * Class  : MethodLikelihood                                                      *
00008  * Web    : http://tmva.sourceforge.net                                           *
00009  *                                                                                *
00010  * Description:                                                                   *
00011  *      Likelihood analysis ("non-parametric approach")                           *
00012  *      Also implemented is a "diagonalized likelihood approach",                 *
00013  *      which improves over the uncorrelated likelihood ansatz by transforming    *
00014  *      linearly the input variables into a diagonal space, using the square-root *
00015  *      of the covariance matrix. This approach can be chosen by inserting        *
00016  *      the letter "D" into the option string.                                    *
00017  *                                                                                *
00018  * Authors (alphabetical):                                                        *
00019  *      Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland              *
00020  *      Helge Voss      <Helge.Voss@cern.ch>     - MPI-K Heidelberg, Germany      *
00021  *      Kai Voss        <Kai.Voss@cern.ch>       - U. of Victoria, Canada         *
00022  *                                                                                *
00023  * Copyright (c) 2005:                                                            *
00024  *      CERN, Switzerland                                                         * 
00025  *      U. of Victoria, Canada                                                    * 
00026  *      MPI-K Heidelberg, Germany                                                 * 
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_MethodLikelihood
00034 #define ROOT_TMVA_MethodLikelihood
00035 
00036 //////////////////////////////////////////////////////////////////////////
00037 //                                                                      //
00038 // MethodLikelihood                                                     //
00039 //                                                                      //
00040 // Likelihood analysis ("non-parametric approach")                      //
00041 // Also implemented is a "diagonalized likelihood approach",            //
00042 // which improves over the uncorrelated likelihood ansatz by            //
00043 // transforming linearly the input variables into a diagonal space,     //
00044 // using the square-root of the covariance matrix                       //
00045 //                                                                      //
00046 //////////////////////////////////////////////////////////////////////////
00047 
00048 #ifndef ROOT_TMVA_MethodBase
00049 #include "TMVA/MethodBase.h"
00050 #endif
00051 #ifndef ROOT_TMVA_PDF
00052 #include "TMVA/PDF.h"
00053 #endif
00054 
00055 class TH1D;
00056 
00057 namespace TMVA {
00058 
00059    class MethodLikelihood : public MethodBase {
00060 
00061    public:
00062 
00063       MethodLikelihood( const TString& jobName, 
00064                         const TString& methodTitle, 
00065                         DataSetInfo& theData,
00066                         const TString& theOption = "",
00067                         TDirectory* theTargetDir = 0 );
00068   
00069       MethodLikelihood( DataSetInfo& theData, 
00070                         const TString& theWeightFile,  
00071                         TDirectory* theTargetDir = NULL );
00072 
00073       virtual ~MethodLikelihood();
00074     
00075       virtual Bool_t HasAnalysisType( Types::EAnalysisType type, 
00076                                       UInt_t numberClasses, UInt_t numberTargets );
00077 
00078       // training method
00079       void Train();
00080 
00081       // write weights to file
00082       void WriteWeightsToStream( TFile& rf ) const;
00083       void AddWeightsXMLTo( void* parent ) const;
00084 
00085       // read weights from file
00086       void ReadWeightsFromStream( istream& istr );
00087       void ReadWeightsFromStream( TFile& istr );
00088       void ReadWeightsFromXML( void* wghtnode );
00089       // calculate the MVA value
00090       // the argument is used for internal ranking tests
00091       Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 );
00092 
00093       // write method specific histos to target file
00094       void WriteMonitoringHistosToFile() const;
00095 
00096       // ranking of input variables
00097       const Ranking* CreateRanking();
00098 
00099       virtual void WriteOptionsToStream ( ostream& o, const TString& prefix ) const;
00100 
00101    protected:
00102 
00103       void DeclareCompatibilityOptions();
00104 
00105       // make ROOT-independent C++ class for classifier response (classifier-specific implementation)
00106       void MakeClassSpecific( std::ostream&, const TString& ) const;
00107 
00108       // header and auxiliary classes
00109       void MakeClassSpecificHeader( std::ostream&, const TString& = "" ) const;
00110 
00111       // get help message text
00112       void GetHelpMessage() const;
00113 
00114    private:
00115 
00116       // returns transformed or non-transformed output
00117       Double_t TransformLikelihoodOutput( Double_t ps, Double_t pb ) const;
00118 
00119       // the option handling methods
00120       void Init();
00121       void DeclareOptions();
00122       void ProcessOptions();
00123       
00124       // options
00125       Double_t             fEpsilon;                   // minimum number of likelihood (to avoid zero)
00126       Bool_t               fTransformLikelihoodOutput; // likelihood output is sigmoid-transformed
00127 
00128       Int_t                fDropVariable;              //  for ranking test
00129       
00130       std::vector<TH1*>*   fHistSig;                   // signal PDFs (histograms)
00131       std::vector<TH1*>*   fHistBgd;                   // background PDFs (histograms)
00132       std::vector<TH1*>*   fHistSig_smooth;            // signal PDFs (smoothed histograms)
00133       std::vector<TH1*>*   fHistBgd_smooth;            // background PDFs (smoothed histograms)
00134   
00135       PDF*                 fDefaultPDFLik;             // pdf that contains default definitions
00136       std::vector<PDF*>*   fPDFSig;                    // list of PDFs (signal)    
00137       std::vector<PDF*>*   fPDFBgd;                    // list of PDFs (background)
00138 
00139       // default initialisation called by all constructors
00140 
00141       // obsolete variables kept for backward combatibility
00142       Int_t                fNsmooth;                   // number of smooth passes
00143       Int_t*               fNsmoothVarS;               // number of smooth passes
00144       Int_t*               fNsmoothVarB;               // number of smooth passes
00145       Int_t                fAverageEvtPerBin;          // average events per bin; used to calculate fNbins
00146       Int_t*               fAverageEvtPerBinVarS;      // average events per bin; used to calculate fNbins
00147       Int_t*               fAverageEvtPerBinVarB;      // average events per bin; used to calculate fNbins
00148       TString              fBorderMethodString;        // the method to take care about "border" effects (string)
00149       Float_t              fKDEfineFactor;             // fine tuning factor for Adaptive KDE
00150       TString              fKDEiterString;             // Number of iterations (string)
00151       TString              fKDEtypeString;             // Kernel type to use for KDE (string)
00152       TString*             fInterpolateString;         // which interpolation method used for reference histograms (individual for each variable)
00153    
00154       ClassDef(MethodLikelihood,0) // Likelihood analysis ("non-parametric approach") 
00155    };
00156 
00157 } // namespace TMVA
00158 
00159 #endif // MethodLikelihood_H

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