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
52 const TString& methodTitle,
54 const TString& theOption = "3000:N-1:N-2");
55
57 const TString& theWeightFile);
58
59 virtual ~MethodTMlpANN( void );
60
62
63 // training method
64 void Train( void ) override;
65
67
68 // write weights to file
69 void AddWeightsXMLTo( void* parent ) const override;
70
71 // read weights from file
72 void ReadWeightsFromStream( std::istream& istr ) override;
73 void ReadWeightsFromXML(void* wghtnode) override;
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 ) override;
80
82
83 // ranking of input variables
84 const Ranking* CreateRanking() override { return nullptr; }
85
86 // make ROOT-independent C++ class
87 void MakeClass( const TString& classFileName = TString("") ) const override;
88
89 protected:
90
91 // make ROOT-independent C++ class for classifier response (classifier-specific implementation)
92 void MakeClassSpecific( std::ostream&, const TString& ) const override;
93
94 // get help message text
95 void GetHelpMessage() const override;
96
97 private:
98
99 // the option handling methods
100 void DeclareOptions() override;
101 void ProcessOptions() override;
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 ) override;
120
121 ClassDefOverride(MethodTMlpANN,0); // Implementation of interface for TMultiLayerPerceptron
122 };
123
124} // namespace TMVA
125
126#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
void ReadWeightsFromStream(std::istream &) override=0
This is the TMVA TMultiLayerPerceptron interface class.
Double_t fValidationFraction
fraction of events in training tree used for cross validation
void ReadWeightsFromStream(std::istream &istr) override
read weights from stream since the MLP can not read from the stream, we 1st: write the weights to tem...
void MakeClass(const TString &classFileName=TString("")) const override
create reader class for classifier -> overwrites base class function create specific class for TMulti...
void Train(void) override
performs TMlpANN training available learning methods:
const Ranking * CreateRanking() override
TString fLearningMethod
the learning method (given via option string)
TString fMLPBuildOptions
option string to build the mlp
void ReadWeightsFromXML(void *wghtnode) override
rebuild temporary textfile from xml weightfile and load this file into MLP
void AddWeightsXMLTo(void *parent) const override
write weights to xml file
void DeclareOptions() override
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 ProcessOptions() override
builds the neural network as specified by the user
MethodTMlpANN(const TString &jobName, const TString &methodTitle, DataSetInfo &theData, const TString &theOption="3000:N-1:N-2")
standard constructor
TMultiLayerPerceptron * fMLP
the TMLP
Double_t GetMvaValue(Double_t *err=nullptr, Double_t *errUpper=nullptr) override
calculate the value of the neural net for the current event
TString fLayerSpec
Layer specification option.
void Init(void) override
default initialisations
virtual ~MethodTMlpANN(void)
destructor
Int_t fNcycles
number of training cycles
Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets) override
TMlpANN can handle classification with 2 classes.
void GetHelpMessage() const override
get help message text
void MakeClassSpecific(std::ostream &, const TString &) const override
write specific classifier response nothing to do here - all taken care of by TMultiLayerPerceptron
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:89
create variable transformations