Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 * *
9 * *
10 * Description: *
11 * Implementation of interface for Root-integrated artificial neural *
12 * network: TMultiLayerPerceptron, author: Christophe.Delaere@cern.ch *
13 * *
14 * Authors (alphabetical): *
15 * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
16 * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
17 * Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada *
18 * *
19 * Copyright (c) 2005: *
20 * CERN, Switzerland *
21 * U. of Victoria, Canada *
22 * MPI-K Heidelberg, Germany *
23 * *
24 * Redistribution and use in source and binary forms, with or without *
25 * modification, are permitted according to the terms listed in LICENSE *
26 * (see tmva/doc/LICENSE) *
27 **********************************************************************************/
28
29#ifndef ROOT_TMVA_MethodTMlpANN
30#define ROOT_TMVA_MethodTMlpANN
31
32//////////////////////////////////////////////////////////////////////////
33// //
34// MethodTMlpANN //
35// //
36// Implementation of interface for Root-integrated artificial neural //
37// network: TMultiLayerPerceptron //
38// //
39//////////////////////////////////////////////////////////////////////////
40
41#include "TMVA/MethodBase.h"
42
44
45namespace TMVA {
46
47 class MethodTMlpANN : public MethodBase {
48
49 public:
50
51 MethodTMlpANN( const TString& jobName,
52 const TString& methodTitle,
53 DataSetInfo& theData,
54 const TString& theOption = "3000:N-1:N-2");
55
56 MethodTMlpANN( DataSetInfo& theData,
57 const TString& theWeightFile);
58
59 virtual ~MethodTMlpANN( void );
60
61 virtual Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
62
63 // training method
64 void Train( void );
65
67
68 // write weights to file
69 void AddWeightsXMLTo( void* parent ) const;
70
71 // read weights from file
72 void ReadWeightsFromStream( std::istream& istr );
73 void ReadWeightsFromXML(void* wghtnode);
74
75 // calculate the MVA value ...
76 // - here it is just a dummy, as it is done in the overwritten
77 // - PrepareEvaluationtree... ugly but necessary due to the structure
78 // of TMultiLayerPercepton in ROOT grr... :-(
79 Double_t GetMvaValue( Double_t* err = nullptr, Double_t* errUpper = nullptr );
80
81 void SetHiddenLayer(TString hiddenlayer = "" ) { fHiddenLayer=hiddenlayer; }
82
83 // ranking of input variables
84 const Ranking* CreateRanking() { return nullptr; }
85
86 // make ROOT-independent C++ class
87 void MakeClass( const TString& classFileName = TString("") ) const;
88
89 protected:
90
91 // make ROOT-independent C++ class for classifier response (classifier-specific implementation)
92 void MakeClassSpecific( std::ostream&, const TString& ) const;
93
94 // get help message text
95 void GetHelpMessage() const;
96
97 private:
98
99 // the option handling methods
100 void DeclareOptions();
101 void ProcessOptions();
102
104
105 // option string
106 TString fLayerSpec; ///< Layer specification option
107
109 TTree* fLocalTrainingTree; ///< local copy of training tree
110
111 TString fHiddenLayer; ///< string containing the hidden layer structure
112 Int_t fNcycles; ///< number of training cycles
113 Double_t fValidationFraction; ///< fraction of events in training tree used for cross validation
114 TString fMLPBuildOptions; ///< option string to build the mlp
115
116 TString fLearningMethod; ///< the learning method (given via option string)
117
118 // default initialisation called by all constructors
119 void Init( void );
120
121 ClassDef(MethodTMlpANN,0); // Implementation of interface for TMultiLayerPerceptron
122 };
123
124} // namespace TMVA
125
126#endif
#define ClassDef(name, id)
Definition Rtypes.h:342
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Class that contains all the data information.
Definition DataSetInfo.h:62
Virtual base Class for all MVA method.
Definition MethodBase.h:111
virtual void ReadWeightsFromStream(std::istream &)=0
This is the TMVA TMultiLayerPerceptron interface class.
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...
Double_t fValidationFraction
fraction of events in training tree used for cross validation
void Init(void)
default initialisations
TString fLearningMethod
the learning method (given via option string)
TString fMLPBuildOptions
option string to build the mlp
virtual Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
TMlpANN can handle classification with 2 classes.
const Ranking * CreateRanking()
void Train(void)
performs TMlpANN training available learning methods:
Double_t GetMvaValue(Double_t *err=nullptr, Double_t *errUpper=nullptr)
calculate the value of the neural net for the current event
void DeclareOptions()
define the options (their key words) that can be set in the option string
TTree * fLocalTrainingTree
local copy of training tree
void CreateMLPOptions(TString)
translates options from option string into TMlpANN language
void ReadWeightsFromXML(void *wghtnode)
rebuild temporary textfile from xml weightfile and load this file into MLP
void ProcessOptions()
builds the neural network as specified by the user
void MakeClassSpecific(std::ostream &, const TString &) const
write specific classifier response nothing to do here - all taken care of by TMultiLayerPerceptron
TMultiLayerPerceptron * fMLP
the TMLP
void AddWeightsXMLTo(void *parent) const
write weights to xml file
void MakeClass(const TString &classFileName=TString("")) const
create reader class for classifier -> overwrites base class function create specific class for TMulti...
TString fLayerSpec
Layer specification option.
virtual ~MethodTMlpANN(void)
destructor
Int_t fNcycles
number of training cycles
void GetHelpMessage() const
get help message text
TString fHiddenLayer
string containing the hidden layer structure
void SetHiddenLayer(TString hiddenlayer="")
Ranking for variables in method (implementation)
Definition Ranking.h:48
This class describes a neural network.
Basic string class.
Definition TString.h:139
A TTree represents a columnar dataset.
Definition TTree.h:79
create variable transformations