00001 // @(#)root/tmva $Id: MethodTMlpANN.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 : MethodTMlpANN * 00008 * Web : http://tmva.sourceforge.net * 00009 * * 00010 * Description: * 00011 * Implementation of interface for Root-integrated artificial neural * 00012 * network: TMultiLayerPerceptron, author: Christophe.Delaere@cern.ch * 00013 * for a manual, see * 00014 * http://root.cern.ch/root/html/TMultiLayerPerceptron.html * 00015 * * 00016 * Authors (alphabetical): * 00017 * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland * 00018 * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany * 00019 * Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada * 00020 * * 00021 * Copyright (c) 2005: * 00022 * CERN, Switzerland * 00023 * U. of Victoria, Canada * 00024 * MPI-K Heidelberg, Germany * 00025 * * 00026 * Redistribution and use in source and binary forms, with or without * 00027 * modification, are permitted according to the terms listed in LICENSE * 00028 * (http://tmva.sourceforge.net/LICENSE) * 00029 **********************************************************************************/ 00030 00031 #ifndef ROOT_TMVA_MethodTMlpANN 00032 #define ROOT_TMVA_MethodTMlpANN 00033 00034 ////////////////////////////////////////////////////////////////////////// 00035 // // 00036 // MethodTMlpANN // 00037 // // 00038 // Implementation of interface for Root-integrated artificial neural // 00039 // network: TMultiLayerPerceptron // 00040 // // 00041 ////////////////////////////////////////////////////////////////////////// 00042 00043 #ifndef ROOT_TMVA_MethodBase 00044 #include "TMVA/MethodBase.h" 00045 #endif 00046 00047 class TMultiLayerPerceptron; 00048 00049 namespace TMVA { 00050 00051 class MethodTMlpANN : public MethodBase { 00052 00053 public: 00054 00055 MethodTMlpANN( const TString& jobName, 00056 const TString& methodTitle, 00057 DataSetInfo& theData, 00058 const TString& theOption = "3000:N-1:N-2", 00059 TDirectory* theTargetDir = 0 ); 00060 00061 MethodTMlpANN( DataSetInfo& theData, 00062 const TString& theWeightFile, 00063 TDirectory* theTargetDir = NULL ); 00064 00065 virtual ~MethodTMlpANN( void ); 00066 00067 virtual Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets ); 00068 00069 // training method 00070 void Train( void ); 00071 00072 using MethodBase::ReadWeightsFromStream; 00073 00074 // write weights to file 00075 void AddWeightsXMLTo( void* parent ) const; 00076 00077 // read weights from file 00078 void ReadWeightsFromStream( istream& istr ); 00079 void ReadWeightsFromXML(void* wghtnode); 00080 00081 // calculate the MVA value ... 00082 // - here it is just a dummy, as it is done in the overwritten 00083 // - PrepareEvaluationtree... ugly but necessary due to the strucure 00084 // of TMultiLayerPercepton in ROOT grr... :-( 00085 Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 ); 00086 00087 void SetHiddenLayer(TString hiddenlayer = "" ) { fHiddenLayer=hiddenlayer; } 00088 00089 // ranking of input variables 00090 const Ranking* CreateRanking() { return 0; } 00091 00092 // make ROOT-independent C++ class 00093 void MakeClass( const TString& classFileName = TString("") ) const; 00094 00095 protected: 00096 00097 // make ROOT-independent C++ class for classifier response (classifier-specific implementation) 00098 void MakeClassSpecific( std::ostream&, const TString& ) const; 00099 00100 // get help message text 00101 void GetHelpMessage() const; 00102 00103 private: 00104 00105 // the option handling methods 00106 void DeclareOptions(); 00107 void ProcessOptions(); 00108 00109 void CreateMLPOptions( TString ); 00110 00111 // option string 00112 TString fLayerSpec; // Layer specification option 00113 00114 TMultiLayerPerceptron* fMLP; // the TMLP 00115 TTree* fLocalTrainingTree; // local copy of training tree 00116 00117 TString fHiddenLayer; // string containig the hidden layer structure 00118 Int_t fNcycles; // number of training cylcles 00119 Double_t fValidationFraction; // fraction of events in training tree used for cross validation 00120 TString fMLPBuildOptions; // option string to build the mlp 00121 00122 TString fLearningMethod; // the learning method (given via option string) 00123 00124 // default initialisation called by all constructors 00125 void Init( void ); 00126 00127 ClassDef(MethodTMlpANN,0) // Implementation of interface for TMultiLayerPerceptron 00128 }; 00129 00130 } // namespace TMVA 00131 00132 #endif