|
||||
File indexing completed on 2025-01-18 10:11:00
0001 // @(#)root/tmva $Id$ 0002 // Author: Andreas Hoecker, Peter Speckmayer 0003 0004 /********************************************************************************** 0005 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis * 0006 * Package: TMVA * 0007 * Class : MethodFDA * 0008 * * 0009 * * 0010 * Description: * 0011 * Function discriminant analysis (FDA). This simple classifier * 0012 * fits any user-defined TFormula (via option configuration string) to * 0013 * the training data by requiring a formula response of 1 (0) to signal * 0014 * (background) events. The parameter fitting is done via the abstract * 0015 * class FitterBase, featuring Monte Carlo sampling, Genetic * 0016 * Algorithm, Simulated Annealing, MINUIT and combinations of these. * 0017 * * 0018 * Authors (alphabetical): * 0019 * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland * 0020 * Peter Speckmayer <speckmay@mail.cern.ch> - CERN, Switzerland * 0021 * * 0022 * Copyright (c) 2005-2010: * 0023 * CERN, Switzerland * 0024 * MPI-K Heidelberg, Germany * 0025 * * 0026 * Redistribution and use in source and binary forms, with or without * 0027 * modification, are permitted according to the terms listed in LICENSE * 0028 * (see tmva/doc/LICENSE) * 0029 **********************************************************************************/ 0030 0031 #ifndef ROOT_TMVA_MethodFDA 0032 #define ROOT_TMVA_MethodFDA 0033 0034 ////////////////////////////////////////////////////////////////////////// 0035 // // 0036 // MethodFDA // 0037 // // 0038 // Function discriminant analysis (FDA). This simple classifier // 0039 // fits any user-defined TFormula (via option configuration string) to // 0040 // the training data by requiring a formula response of 1 (0) to signal // 0041 // (background) events. The parameter fitting is done via the abstract // 0042 // class FitterBase, featuring Monte Carlo sampling, Genetic // 0043 // Algorithm, Simulated Annealing, MINUIT and combinations of these. // 0044 // // 0045 // Can compute one-dimensional regression // 0046 // // 0047 ////////////////////////////////////////////////////////////////////////// 0048 0049 #include "TMVA/MethodBase.h" 0050 #include "TMVA/IFitterTarget.h" 0051 #include <vector> 0052 0053 class TFormula; 0054 0055 namespace TMVA { 0056 0057 class Interval; 0058 class Event; 0059 class FitterBase; 0060 0061 class MethodFDA : public MethodBase, public IFitterTarget { 0062 0063 public: 0064 0065 MethodFDA( const TString& jobName, 0066 const TString& methodTitle, 0067 DataSetInfo& theData, 0068 const TString& theOption = ""); 0069 0070 MethodFDA( DataSetInfo& theData, 0071 const TString& theWeightFile); 0072 0073 virtual ~MethodFDA( void ); 0074 0075 Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets ); 0076 0077 // training method 0078 void Train( void ); 0079 0080 using MethodBase::ReadWeightsFromStream; 0081 0082 void AddWeightsXMLTo ( void* parent ) const; 0083 0084 void ReadWeightsFromStream( std::istream & i ); 0085 void ReadWeightsFromXML ( void* wghtnode ); 0086 0087 // calculate the MVA value 0088 Double_t GetMvaValue( Double_t* err = nullptr, Double_t* errUpper = nullptr ); 0089 0090 virtual const std::vector<Float_t>& GetRegressionValues(); 0091 virtual const std::vector<Float_t>& GetMulticlassValues(); 0092 0093 void Init( void ); 0094 0095 // ranking of input variables 0096 const Ranking* CreateRanking() { return nullptr; } 0097 0098 Double_t EstimatorFunction( std::vector<Double_t>& ); 0099 0100 // no check of options at this place 0101 void CheckSetup() {} 0102 0103 protected: 0104 0105 // make ROOT-independent C++ class for classifier response (classifier-specific implementation) 0106 void MakeClassSpecific( std::ostream&, const TString& ) const; 0107 0108 // get help message text 0109 void GetHelpMessage() const; 0110 0111 private: 0112 0113 // compute multiclass values 0114 void CalculateMulticlassValues( const TMVA::Event*& evt, std::vector<Double_t>& parameters, std::vector<Float_t>& values); 0115 0116 0117 // create and interpret formula expression and compute estimator 0118 void CreateFormula (); 0119 Double_t InterpretFormula( const Event*, std::vector<Double_t>::iterator begin, std::vector<Double_t>::iterator end ); 0120 0121 // clean up 0122 void ClearAll(); 0123 0124 // print fit results 0125 void PrintResults( const TString&, std::vector<Double_t>&, const Double_t ) const; 0126 0127 // the option handling methods 0128 void DeclareOptions(); 0129 void ProcessOptions(); 0130 0131 TString fFormulaStringP; ///< string with function 0132 TString fParRangeStringP; ///< string with ranges of parameters 0133 TString fFormulaStringT; ///< string with function 0134 TString fParRangeStringT; ///< string with ranges of parameters 0135 0136 TFormula* fFormula; ///< the discrimination function 0137 UInt_t fNPars; ///< number of parameters 0138 std::vector<Interval*> fParRange; ///< ranges of parameters 0139 std::vector<Double_t> fBestPars; ///< the pars that optimise (minimise) the estimator 0140 TString fFitMethod; ///< estimator optimisation method 0141 TString fConverger; ///< fit method uses fConverger as intermediate step to converge into local minimas 0142 FitterBase* fFitter; ///< the fitter used in the training 0143 IFitterTarget* fConvergerFitter; ///< intermediate fitter 0144 0145 0146 // sum of weights (this should become centrally available through the dataset) 0147 Double_t fSumOfWeightsSig; ///< sum of weights (signal) 0148 Double_t fSumOfWeightsBkg; ///< sum of weights (background) 0149 Double_t fSumOfWeights; ///< sum of weights 0150 0151 // 0152 Int_t fOutputDimensions; ///< number of output values 0153 0154 ClassDef(MethodFDA,0); // Function Discriminant Analysis 0155 }; 0156 0157 } // namespace TMVA 0158 0159 #endif // MethodFDA_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |