ROOT  6.06/09
Reference Guide
MethodTMlpANN.h
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : MethodTMlpANN *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Implementation of interface for Root-integrated artificial neural *
12  * network: TMultiLayerPerceptron, author: Christophe.Delaere@cern.ch *
13  * for a manual, see *
14  * http://root.cern.ch/root/html/TMultiLayerPerceptron.html *
15  * *
16  * Authors (alphabetical): *
17  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
18  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
19  * Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada *
20  * *
21  * Copyright (c) 2005: *
22  * CERN, Switzerland *
23  * U. of Victoria, Canada *
24  * MPI-K Heidelberg, Germany *
25  * *
26  * Redistribution and use in source and binary forms, with or without *
27  * modification, are permitted according to the terms listed in LICENSE *
28  * (http://tmva.sourceforge.net/LICENSE) *
29  **********************************************************************************/
30 
31 #ifndef ROOT_TMVA_MethodTMlpANN
32 #define ROOT_TMVA_MethodTMlpANN
33 
34 //////////////////////////////////////////////////////////////////////////
35 // //
36 // MethodTMlpANN //
37 // //
38 // Implementation of interface for Root-integrated artificial neural //
39 // network: TMultiLayerPerceptron //
40 // //
41 //////////////////////////////////////////////////////////////////////////
42 
43 #ifndef ROOT_TMVA_MethodBase
44 #include "TMVA/MethodBase.h"
45 #endif
46 
48 
49 namespace TMVA {
50 
51  class MethodTMlpANN : public MethodBase {
52 
53  public:
54 
55  MethodTMlpANN( const TString& jobName,
56  const TString& methodTitle,
57  DataSetInfo& theData,
58  const TString& theOption = "3000:N-1:N-2",
59  TDirectory* theTargetDir = 0 );
60 
61  MethodTMlpANN( DataSetInfo& theData,
62  const TString& theWeightFile,
63  TDirectory* theTargetDir = NULL );
64 
65  virtual ~MethodTMlpANN( void );
66 
67  virtual Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
68 
69  // training method
70  void Train( void );
71 
73 
74  // write weights to file
75  void AddWeightsXMLTo( void* parent ) const;
76 
77  // read weights from file
78  void ReadWeightsFromStream( std::istream& istr );
79  void ReadWeightsFromXML(void* wghtnode);
80 
81  // calculate the MVA value ...
82  // - here it is just a dummy, as it is done in the overwritten
83  // - PrepareEvaluationtree... ugly but necessary due to the strucure
84  // of TMultiLayerPercepton in ROOT grr... :-(
85  Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 );
86 
87  void SetHiddenLayer(TString hiddenlayer = "" ) { fHiddenLayer=hiddenlayer; }
88 
89  // ranking of input variables
90  const Ranking* CreateRanking() { return 0; }
91 
92  // make ROOT-independent C++ class
93  void MakeClass( const TString& classFileName = TString("") ) const;
94 
95  protected:
96 
97  // make ROOT-independent C++ class for classifier response (classifier-specific implementation)
98  void MakeClassSpecific( std::ostream&, const TString& ) const;
99 
100  // get help message text
101  void GetHelpMessage() const;
102 
103  private:
104 
105  // the option handling methods
106  void DeclareOptions();
107  void ProcessOptions();
108 
109  void CreateMLPOptions( TString );
110 
111  // option string
112  TString fLayerSpec; // Layer specification option
113 
115  TTree* fLocalTrainingTree; // local copy of training tree
116 
117  TString fHiddenLayer; // string containig the hidden layer structure
118  Int_t fNcycles; // number of training cylcles
119  Double_t fValidationFraction; // fraction of events in training tree used for cross validation
120  TString fMLPBuildOptions; // option string to build the mlp
121 
122  TString fLearningMethod; // the learning method (given via option string)
123 
124  // default initialisation called by all constructors
125  void Init( void );
126 
127  ClassDef(MethodTMlpANN,0) // Implementation of interface for TMultiLayerPerceptron
128  };
129 
130 } // namespace TMVA
131 
132 #endif
void Train(void)
performs TMlpANN training available learning methods:
Double_t GetMvaValue(Double_t *err=0, Double_t *errUpper=0)
calculate the value of the neural net for the current event
void MakeClass(const TString &classFileName=TString("")) const
create reader class for classifier -> overwrites base class function create specific class for TMulti...
void GetHelpMessage() const
get help message text
EAnalysisType
Definition: Types.h:124
Double_t fValidationFraction
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
MethodTMlpANN(const TString &jobName, const TString &methodTitle, DataSetInfo &theData, const TString &theOption="3000:N-1:N-2", TDirectory *theTargetDir=0)
void MakeClassSpecific(std::ostream &, const TString &) const
write specific classifier response nothing to do here - all taken care of by TMultiLayerPerceptron ...
#define ClassDef(name, id)
Definition: Rtypes.h:254
void Init(void)
default initialisations
void ReadWeightsFromXML(void *wghtnode)
rebuild temporary textfile from xml weightfile and load this file into MLP
virtual ~MethodTMlpANN(void)
destructor
void ProcessOptions()
builds the neural network as specified by the user
void SetHiddenLayer(TString hiddenlayer="")
Definition: MethodTMlpANN.h:87
unsigned int UInt_t
Definition: RtypesCore.h:42
TMultiLayerPerceptron * fMLP
const Ranking * CreateRanking()
Definition: MethodTMlpANN.h:90
double Double_t
Definition: RtypesCore.h:55
Describe directory structure in memory.
Definition: TDirectory.h:41
int type
Definition: TGX11.cxx:120
void ReadWeightsFromStream(std::istream &istr)
read weights from stream since the MLP can not read from the stream, we 1st: write the weights to tem...
void AddWeightsXMLTo(void *parent) const
write weights to xml file
Abstract ClassifierFactory template that handles arbitrary types.
#define NULL
Definition: Rtypes.h:82
void CreateMLPOptions(TString)
translates options from option string into TMlpANN language
A TTree object has a header with a name and a title.
Definition: TTree.h:94
virtual void ReadWeightsFromStream(std::istream &)=0
void DeclareOptions()
define the options (their key words) that can be set in the option string know options: NCycles
virtual Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
TMlpANN can handle classification with 2 classes.