 |
Belle II Software
release-05-01-25
|
12 #ifndef INCLUDE_GUARD_BELLE2_MVA_TMVA_HEADER
13 #define INCLUDE_GUARD_BELLE2_MVA_TMVA_HEADER
15 #include <mva/interface/Options.h>
16 #include <mva/interface/Teacher.h>
17 #include <mva/interface/Expert.h>
19 #include <TMVA/Factory.h>
20 #include <TMVA/Tools.h>
21 #include <TMVA/Reader.h>
22 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,8,0)
23 #include <TMVA/DataLoader.h>
45 virtual void load(
const boost::property_tree::ptree& pt)
override;
51 virtual void save(boost::property_tree::ptree& pt)
const override;
61 virtual std::string
getMethod()
const override {
return "TMVA"; }
71 "!H:!V:CreateMVAPdfs:NTrees=400:BoostType=Grad:Shrinkage=0.1:UseBaggedBoost:BaggedSampleFraction=0.5:nCuts=1024:MaxDepth=3:IgnoreNegWeightsInTraining";
100 virtual void load(
const boost::property_tree::ptree& pt)
override;
106 virtual void save(boost::property_tree::ptree& pt)
const override;
116 virtual std::string
getMethod()
const override {
return "TMVAClassification"; }
142 virtual void load(
const boost::property_tree::ptree& pt)
override;
148 virtual void save(boost::property_tree::ptree& pt)
const override;
158 virtual std::string
getMethod()
const override {
return "TMVAMulticlass"; }
185 virtual std::string
getMethod()
const override {
return "TMVARegression"; }
202 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,8,0)
209 Weightfile trainFactory(TMVA::Factory& factory, TMVA::DataLoader& data_loader, std::string& jobName)
const;
308 mutable std::vector<float>
310 mutable std::vector<float>
330 virtual std::vector<float>
apply(
Dataset& test_data)
const override;
357 return std::vector<float>();
366 virtual std::vector<float>
apply(
Dataset& test_data,
const unsigned int classID)
const override;
389 virtual std::vector<float>
apply(
Dataset& test_data)
const override;
virtual std::vector< float > apply(Dataset &test_data) const override
Apply this m_expert onto a dataset.
std::string m_config
TMVA config string for the chosen method.
std::string m_prepareOption
Prepare options passed to prepareTrainingAndTestTree method.
virtual void load(const boost::property_tree::ptree &pt) override
Load mechanism to load Options from a xml tree.
virtual Weightfile train(Dataset &training_data) const override
Train a mva method using the given dataset returning a Weightfile.
Expert for the TMVA Classification MVA method.
Teacher for the TMVA Classification MVA method.
virtual void save(boost::property_tree::ptree &pt) const override
Save mechanism to store Options in a xml tree.
TMVATeacherRegression(const GeneralOptions &general_options, const TMVAOptionsRegression &_specific_options)
Constructs a new teacher using the GeneralOptions and specific options of this training.
virtual po::options_description getDescription() override
Returns a program options description for all available options.
virtual void load(const boost::property_tree::ptree &pt) override
Load mechanism to load Options from a xml tree.
std::vector< std::string > m_classes
Class name identifiers.
Abstract base class of all Datasets given to the MVA interface The current event can always be access...
Options for the TMVA Classification MVA method.
Teacher for the TMVA Multiclass MVA method.
The Weightfile class serializes all information about a training into an xml tree.
virtual std::string getMethod() const override
Return method name.
TMVAOptions specific_options
Method specific options.
bool transform2probability
Transform output of method to a probability.
virtual po::options_description getDescription() override
Returns a program options description for all available options.
virtual void load(Weightfile &weightfile) override
Load the expert from a Weightfile.
TMVAOptionsMulticlass specific_options
Method specific options.
virtual std::string getMethod() const override
Return method name.
std::vector< float > m_spectators_cache
Spectators Cache for TMVA::Reader: Otherwise we would have to set the branch addresses in each apply ...
TMVAOptionsMulticlass()
Constructor Adds Multiclass as AnalysisType to the factoryOptions.
Specific Options, all mehtod Options have to inherit from this class.
virtual Weightfile train(Dataset &training_data) const override
Train a mva method using the given dataset returning a Weightfile.
TMVATeacher(const GeneralOptions &general_options, const TMVAOptions &_specific_options)
Constructs a new teacher using the GeneralOptions and specific options of this training.
std::string m_prefix
Prefix used for all files generated by TMVA.
Teacher for the TMVA Regression MVA method.
TMVAOptionsMulticlass specific_options
Method specific options.
TMVAOptionsRegression()
Constructor Adds REgression as AnalysisType to the factoryOptions.
virtual void save(boost::property_tree::ptree &pt) const override
Save mechanism to store Options in a xml tree.
Expert for the TMVA MVA method.
Abstract base class for different kinds of events.
virtual std::vector< float > apply(Dataset &test_data) const override
Apply this m_expert onto a dataset.
Abstract base class of all Teachers Each MVA library has its own implementation of this class,...
TMVAOptionsRegression specific_options
Method specific options.
float expert_signalFraction
Signal fraction used to calculate the probability.
Options for the TMVA Multiclass MVA method.
virtual void load(Weightfile &weightfile) override
Load the expert from a Weightfile.
Abstract base class of all Expert Each MVA library has its own implementation of this class,...
General options which are shared by all MVA trainings.
TMVAOptionsRegression specific_options
Method specific options.
std::string m_method
tmva method name
TMVAOptionsClassification specific_options
Method specific options.
virtual std::string getMethod() const override
Return method name.
std::string m_type
tmva method type
Expert for the TMVA Multiclass MVA method.
TMVATeacherMulticlass(const GeneralOptions &general_options, const TMVAOptionsMulticlass &_specific_options)
Constructs a new teacher using the GeneralOptions and specific options of this training.
Weightfile trainFactory(TMVA::Factory &factory, TMVA::DataLoader &data_loader, std::string &jobName) const
Train a mva method using the given data loader returning a Weightfile.
TMVAOptionsClassification()
Constructor Adds Classification as AnalysisType to the factoryOptions.
virtual po::options_description getDescription() override
Returns a program options description for all available options.
TMVATeacherClassification(const GeneralOptions &general_options, const TMVAOptionsClassification &_specific_options)
Constructs a new teacher using the GeneralOptions and specific options of this training.
virtual void save(boost::property_tree::ptree &pt) const override
Save mechanism to store Options in a xml tree.
Expert for the TMVA Regression MVA method.
TMVAOptionsClassification specific_options
Method specific options.
std::string m_factoryOption
Factory options passed to tmva factory.
Options for the TMVA Regression MVA method.
std::vector< float > m_input_cache
Input Cache for TMVA::Reader: Otherwise we would have to set the branch addresses in each apply call.
std::unique_ptr< TMVA::Reader > m_expert
TMVA::Reader pointer.
virtual std::string getMethod() const override
Return method name.
virtual void load(Weightfile &weightfile) override
Load the expert from a Weightfile.
virtual void load(Weightfile &weightfile) override
Load the expert from a Weightfile.
std::string m_workingDirectory
Working directory of TMVA, if empty a temporary directory is used.
virtual std::vector< float > apply(Dataset &test_data) const override
Apply this m_expert onto a dataset.
virtual Weightfile train(Dataset &training_data) const override
Train a mva method using the given dataset returning a Weightfile.
Teacher for the TMVA MVA method.
Options for the TMVA MVA method.
virtual void load(const boost::property_tree::ptree &pt) override
Load mechanism to load Options from a xml tree.