Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:32:30

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