// @(#)root/tmva $Id: MethodFisher.h 21630 2008-01-10 19:40:44Z brun $ // Author: Andreas Hoecker, Xavier Prudent, Joerg Stelzer, Helge Voss, Kai Voss /********************************************************************************** * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * * Package: TMVA * * Class : MethodFisher * * Web : http://tmva.sourceforge.net * * * * Description: * * Analysis of Fisher discriminant (Fisher or Mahalanobis approach) * * * * Original author of this Fisher-Discriminant implementation: * * Andre Gaidot, CEA-France; * * (Translation from FORTRAN) * * * * Authors (alphabetical): * * Andreas Hoecker - CERN, Switzerland * * Xavier Prudent - LAPP, France * * Helge Voss - MPI-K Heidelberg, Germany * * Kai Voss - U. of Victoria, Canada * * * * Copyright (c) 2005: * * CERN, Switzerland * * U. of Victoria, Canada * * MPI-K Heidelberg, Germany * * LAPP, Annecy, France * * * * Redistribution and use in source and binary forms, with or without * * modification, are permitted according to the terms listed in LICENSE * * (http://tmva.sourceforge.net/LICENSE) * * * **********************************************************************************/ #ifndef ROOT_TMVA_MethodFisher #define ROOT_TMVA_MethodFisher ////////////////////////////////////////////////////////////////////////// // // // MethodFisher // // // // Analysis of Fisher discriminant (Fisher or Mahalanobis approach) // // // ////////////////////////////////////////////////////////////////////////// #include #ifndef ROOT_TMVA_MethodBase #include "TMVA/MethodBase.h" #endif #ifndef ROOT_TMVA_TMatrix #include "TMatrix.h" #endif #ifndef ROOT_TMatrixD #include "TMatrixD.h" #endif class TH1D; namespace TMVA { class MethodFisher : public MethodBase { public: MethodFisher( const TString& jobName, const TString& methodTitle, DataSet& theData, const TString& theOption = "Fisher", TDirectory* theTargetDir = 0 ); MethodFisher( DataSet& theData, const TString& theWeightFile, TDirectory* theTargetDir = NULL ); virtual ~MethodFisher( void ); // training method void Train( void ); using MethodBase::WriteWeightsToStream; using MethodBase::ReadWeightsFromStream; // write weights to stream void WriteWeightsToStream( std::ostream & o) const; // read weights from stream void ReadWeightsFromStream( std::istream & i ); // calculate the MVA value Double_t GetMvaValue(); enum EFisherMethod { kFisher, kMahalanobis }; EFisherMethod GetFisherMethod( void ) { return fFisherMethod; } // ranking of input variables const Ranking* CreateRanking(); protected: // make ROOT-independent C++ class for classifier response (classifier-specific implementation) void MakeClassSpecific( std::ostream&, const TString& ) const; // get help message text void GetHelpMessage() const; private: // the option handling methods void DeclareOptions(); void ProcessOptions(); // Initialization and allocation of matrices void InitMatrices( void ); // get mean value of variables void GetMean( void ); // get matrix of covariance within class void GetCov_WithinClass( void ); // get matrix of covariance between class void GetCov_BetweenClass( void ); // and the full covariance matrix void GetCov_Full( void ); // get discriminating power void GetDiscrimPower( void ); // nice output void PrintCoefficients( void ); // get Fisher coefficients void GetFisherCoeff( void ); // matrix of variables means: S, B, S+B vs. variables TMatrixD *fMeanMatx; // method to be used TString fTheMethod; // Fisher or Mahalanobis EFisherMethod fFisherMethod; // Fisher or Mahalanobis // covariance matrices TMatrixD *fBetw; // between-class matrix TMatrixD *fWith; // within-class matrix TMatrixD *fCov; // full covariance matrix // number of events (sumOfWeights) Double_t fSumOfWeightsS; // sum-of-weights for signal training events Double_t fSumOfWeightsB; // sum-of-weights for background training events std::vector *fDiscrimPow; // discriminating power std::vector *fFisherCoeff; // Fisher coefficients Double_t fF0; // offset // default initialisation called by all constructors void InitFisher( void ); ClassDef(MethodFisher,0) // Analysis of Fisher discriminant (Fisher or Mahalanobis approach) }; } // namespace TMVA #endif // MethodFisher_H