Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:22:54

0001 // @(#)root/tmva $Id$
0002 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss
0003 
0004 /**********************************************************************************
0005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
0006  * Package: TMVA                                                                  *
0007  * Class  : MethodTMlpANN                                                         *
0008  *                                             *
0009  *                                                                                *
0010  * Description:                                                                   *
0011  *      Implementation of interface for Root-integrated artificial neural         *
0012  *      network: TMultiLayerPerceptron, author: Christophe.Delaere@cern.ch        *
0013  *      for a manual, see                                                         *
0014  *      http://root.cern.ch/root/html/TMultiLayerPerceptron.html                  *
0015  *                                                                                *
0016  * Authors (alphabetical):                                                        *
0017  *      Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland              *
0018  *      Helge Voss      <Helge.Voss@cern.ch>     - MPI-K Heidelberg, Germany      *
0019  *      Kai Voss        <Kai.Voss@cern.ch>       - U. of Victoria, Canada         *
0020  *                                                                                *
0021  * Copyright (c) 2005:                                                            *
0022  *      CERN, Switzerland                                                         *
0023  *      U. of Victoria, Canada                                                    *
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_MethodTMlpANN
0032 #define ROOT_TMVA_MethodTMlpANN
0033 
0034 //////////////////////////////////////////////////////////////////////////
0035 //                                                                      //
0036 // MethodTMlpANN                                                        //
0037 //                                                                      //
0038 // Implementation of interface for Root-integrated artificial neural    //
0039 // network: TMultiLayerPerceptron                                       //
0040 //                                                                      //
0041 //////////////////////////////////////////////////////////////////////////
0042 
0043 #include "TMVA/MethodBase.h"
0044 
0045 class TMultiLayerPerceptron;
0046 
0047 namespace TMVA {
0048 
0049    class MethodTMlpANN : public MethodBase {
0050 
0051    public:
0052 
0053       MethodTMlpANN( const TString& jobName,
0054                      const TString& methodTitle,
0055                      DataSetInfo& theData,
0056                      const TString& theOption = "3000:N-1:N-2");
0057 
0058       MethodTMlpANN( DataSetInfo& theData,
0059                      const TString& theWeightFile);
0060 
0061       virtual ~MethodTMlpANN( void );
0062 
0063       virtual Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
0064 
0065       // training method
0066       void Train( void );
0067 
0068       using MethodBase::ReadWeightsFromStream;
0069 
0070       // write weights to file
0071       void AddWeightsXMLTo( void* parent ) const;
0072 
0073       // read weights from file
0074       void ReadWeightsFromStream( std::istream& istr );
0075       void ReadWeightsFromXML(void* wghtnode);
0076 
0077       // calculate the MVA value ...
0078       // - here it is just a dummy, as it is done in the overwritten
0079       // - PrepareEvaluationtree... ugly but necessary due to the structure
0080       //   of TMultiLayerPercepton in ROOT grr... :-(
0081       Double_t GetMvaValue( Double_t* err = nullptr, Double_t* errUpper = nullptr );
0082 
0083       void SetHiddenLayer(TString hiddenlayer = "" ) { fHiddenLayer=hiddenlayer; }
0084 
0085       // ranking of input variables
0086       const Ranking* CreateRanking() { return nullptr; }
0087 
0088       // make ROOT-independent C++ class
0089       void MakeClass( const TString& classFileName = TString("") ) const;
0090 
0091    protected:
0092 
0093       // make ROOT-independent C++ class for classifier response (classifier-specific implementation)
0094       void MakeClassSpecific( std::ostream&, const TString& ) const;
0095 
0096       // get help message text
0097       void GetHelpMessage() const;
0098 
0099    private:
0100 
0101       // the option handling methods
0102       void DeclareOptions();
0103       void ProcessOptions();
0104 
0105       void CreateMLPOptions( TString );
0106 
0107       // option string
0108       TString fLayerSpec;          ///< Layer specification option
0109 
0110       TMultiLayerPerceptron* fMLP; ///< the TMLP
0111       TTree*                 fLocalTrainingTree; ///< local copy of training tree
0112 
0113       TString  fHiddenLayer;        ///< string containing the hidden layer structure
0114       Int_t    fNcycles;            ///< number of training cycles
0115       Double_t fValidationFraction; ///< fraction of events in training tree used for cross validation
0116       TString  fMLPBuildOptions;    ///< option string to build the mlp
0117 
0118       TString  fLearningMethod;     ///< the learning method (given via option string)
0119 
0120       // default initialisation called by all constructors
0121       void Init( void );
0122 
0123       ClassDef(MethodTMlpANN,0); // Implementation of interface for TMultiLayerPerceptron
0124    };
0125 
0126 } // namespace TMVA
0127 
0128 #endif