Belle II Software development
FastBDTOptions Class Reference

Options for the FANN MVA method. More...

#include <FastBDT.h>

Inheritance diagram for FastBDTOptions:
SpecificOptions Options

Public Member Functions

virtual void load (const boost::property_tree::ptree &pt) override
 Load mechanism to load Options from a xml tree.
 
virtual void save (boost::property_tree::ptree &pt) const override
 Save mechanism to store Options in a xml tree.
 
virtual po::options_description getDescription () override
 Returns a program options description for all available options.
 
virtual std::string getMethod () const override
 Return method name.
 

Public Attributes

unsigned int m_nTrees = 200
 Number of trees.
 
unsigned int m_nCuts = 8
 Number of cut Levels = log_2(Number of Cuts)
 
unsigned int m_nLevels = 3
 Depth of tree.
 
double m_shrinkage = 0.1
 Shrinkage during the boosting step.
 
double m_randRatio = 0.5
 Fraction of data to use in the stochastic training.
 
std::vector< unsigned int > m_individual_nCuts
 Number of cut Levels = log_2(Number of Cuts) for each provided feature.
 
double m_flatnessLoss = -1.0
 Flatness Loss constant.
 
bool m_sPlot = false
 Activates sPlot sampling.
 
bool m_purityTransformation = false
 Activates purity transformation globally for all features.
 
std::vector< bool > m_individualPurityTransformation
 Vector which decided for each feature individually if the purity transformation should be used.
 

Detailed Description

Options for the FANN MVA method.

Definition at line 37 of file FastBDT.h.

Member Function Documentation

◆ getDescription()

po::options_description getDescription ( )
overridevirtual

Returns a program options description for all available options.

Implements Options.

Definition at line 89 of file FastBDT.cc.

90 {
91 po::options_description description("FastBDT options");
92 description.add_options()
93 ("nTrees", po::value<unsigned int>(&m_nTrees), "Number of trees in the forest. Reasonable values are between 10 and 1000")
94 ("nLevels", po::value<unsigned int>(&m_nLevels)->notifier(check_bounds<unsigned int>(0, 20, "nLevels")),
95 "Depth d of trees. The last layer of the tree will contain 2^d bins. Maximum is 20. Reasonable values are 2 and 6.")
96 ("shrinkage", po::value<double>(&m_shrinkage)->notifier(check_bounds<double>(0.0, 1.0, "shrinkage")),
97 "Shrinkage of the boosting algorithm. Reasonable values are between 0.01 and 1.0.")
98 ("nCutLevels", po::value<unsigned int>(&m_nCuts)->notifier(check_bounds<unsigned int>(0, 20, "nCutLevels")),
99 "Number of cut levels N per feature. 2^N Bins will be used per feature. Reasonable values are between 6 and 12.")
100 ("individualNCutLevels", po::value<std::vector<unsigned int>>(&m_individual_nCuts)->multitoken()->notifier(
101 check_bounds_vector<unsigned int>(0, 20, "individualNCutLevels")),
102 "Number of cut levels N per feature. 2^N Bins will be used per feature. Reasonable values are between 6 and 12. One value per feature (including spectators) should be provided, if parameter is not set the global value specified by nCutLevels is used for all features.")
103 ("sPlot", po::value<bool>(&m_sPlot),
104 "Since in sPlot each event enters twice, this option modifies the sampling algorithm so that the matching signal and background events are selected together.")
105 ("flatnessLoss", po::value<double>(&m_flatnessLoss),
106 "Activate Flatness Loss, all spectator variables are assumed to be variables in which the signal and background efficiency should be flat. negative values deactivates flatness loss.")
107 ("purityTransformation", po::value<bool>(&m_purityTransformation),
108 "Activates purity transformation on all features: Add the purity transformed of all features in addition to the training. This will double the number of features and slow down the inference considerably")
109 ("individualPurityTransformation", po::value<std::vector<bool>>(&m_individualPurityTransformation)->multitoken(),
110 "Activates purity transformation for each feature: Vector of boolean values which decide if the purity transformed of the feature should be added in addition to this training.")
111 ("randRatio", po::value<double>(&m_randRatio)->notifier(check_bounds<double>(0.0, 1.0001, "randRatio")),
112 "Fraction of the data sampled each training iteration. Reasonable values are between 0.1 and 1.0.");
113 return description;
114 }
std::vector< unsigned int > m_individual_nCuts
Number of cut Levels = log_2(Number of Cuts) for each provided feature.
Definition: FastBDT.h:68
bool m_sPlot
Activates sPlot sampling.
Definition: FastBDT.h:70
double m_randRatio
Fraction of data to use in the stochastic training.
Definition: FastBDT.h:66
double m_flatnessLoss
Flatness Loss constant.
Definition: FastBDT.h:69
double m_shrinkage
Shrinkage during the boosting step.
Definition: FastBDT.h:65
bool m_purityTransformation
Activates purity transformation globally for all features.
Definition: FastBDT.h:71
unsigned int m_nLevels
Depth of tree.
Definition: FastBDT.h:64
std::vector< bool > m_individualPurityTransformation
Vector which decided for each feature individually if the purity transformation should be used.
Definition: FastBDT.h:73
unsigned int m_nCuts
Number of cut Levels = log_2(Number of Cuts)
Definition: FastBDT.h:63
unsigned int m_nTrees
Number of trees.
Definition: FastBDT.h:62

◆ getMethod()

virtual std::string getMethod ( ) const
inlineoverridevirtual

Return method name.

Implements SpecificOptions.

Definition at line 60 of file FastBDT.h.

60{ return "FastBDT"; }

◆ load()

void load ( const boost::property_tree::ptree &  pt)
overridevirtual

Load mechanism to load Options from a xml tree.

Parameters
ptxml tree

Implements Options.

Definition at line 31 of file FastBDT.cc.

32 {
33 int version = pt.get<int>("FastBDT_version");
34 if (version != 1 and version != 2) {
35 B2ERROR("Unknown weightfile version " << std::to_string(version));
36 throw std::runtime_error("Unknown weightfile version " + std::to_string(version));
37 }
38 m_nTrees = pt.get<int>("FastBDT_nTrees");
39 m_nCuts = pt.get<int>("FastBDT_nCuts");
40 m_nLevels = pt.get<int>("FastBDT_nLevels");
41 m_shrinkage = pt.get<double>("FastBDT_shrinkage");
42 m_randRatio = pt.get<double>("FastBDT_randRatio");
43
44 if (version > 1) {
45
46 m_flatnessLoss = pt.get<double>("FastBDT_flatnessLoss");
47 m_sPlot = pt.get<bool>("FastBDT_sPlot");
48
49 unsigned int numberOfIndividualNCuts = pt.get<unsigned int>("FastBDT_number_individual_nCuts", 0);
50 m_individual_nCuts.resize(numberOfIndividualNCuts);
51 for (unsigned int i = 0; i < numberOfIndividualNCuts; ++i) {
52 m_individual_nCuts[i] = pt.get<unsigned int>(std::string("FastBDT_individual_nCuts") + std::to_string(i));
53 }
54
55 m_purityTransformation = pt.get<bool>("FastBDT_purityTransformation");
56 unsigned int numberOfIndividualPurityTransformation = pt.get<unsigned int>("FastBDT_number_individualPurityTransformation", 0);
57 m_individualPurityTransformation.resize(numberOfIndividualPurityTransformation);
58 for (unsigned int i = 0; i < numberOfIndividualPurityTransformation; ++i) {
59 m_individualPurityTransformation[i] = pt.get<bool>(std::string("FastBDT_individualPurityTransformation") + std::to_string(i));
60 }
61
62 } else {
63 m_flatnessLoss = -1.0;
64 m_sPlot = false;
65 }
66 }

◆ save()

void save ( boost::property_tree::ptree &  pt) const
overridevirtual

Save mechanism to store Options in a xml tree.

Parameters
ptxml tree

Implements Options.

Definition at line 68 of file FastBDT.cc.

69 {
70 pt.put("FastBDT_version", 2);
71 pt.put("FastBDT_nTrees", m_nTrees);
72 pt.put("FastBDT_nCuts", m_nCuts);
73 pt.put("FastBDT_nLevels", m_nLevels);
74 pt.put("FastBDT_shrinkage", m_shrinkage);
75 pt.put("FastBDT_randRatio", m_randRatio);
76 pt.put("FastBDT_flatnessLoss", m_flatnessLoss);
77 pt.put("FastBDT_sPlot", m_sPlot);
78 pt.put("FastBDT_number_individual_nCuts", m_individual_nCuts.size());
79 for (unsigned int i = 0; i < m_individual_nCuts.size(); ++i) {
80 pt.put(std::string("FastBDT_individual_nCuts") + std::to_string(i), m_individual_nCuts[i]);
81 }
82 pt.put("FastBDT_purityTransformation", m_purityTransformation);
83 pt.put("FastBDT_number_individualPurityTransformation", m_individualPurityTransformation.size());
84 for (unsigned int i = 0; i < m_individualPurityTransformation.size(); ++i) {
85 pt.put(std::string("FastBDT_individualPurityTransformation") + std::to_string(i), m_individualPurityTransformation[i]);
86 }
87 }

Member Data Documentation

◆ m_flatnessLoss

double m_flatnessLoss = -1.0

Flatness Loss constant.

Definition at line 69 of file FastBDT.h.

◆ m_individual_nCuts

std::vector<unsigned int> m_individual_nCuts

Number of cut Levels = log_2(Number of Cuts) for each provided feature.

If empty m_nCuts is used for all features

Definition at line 68 of file FastBDT.h.

◆ m_individualPurityTransformation

std::vector<bool> m_individualPurityTransformation

Vector which decided for each feature individually if the purity transformation should be used.

Definition at line 73 of file FastBDT.h.

◆ m_nCuts

unsigned int m_nCuts = 8

Number of cut Levels = log_2(Number of Cuts)

Definition at line 63 of file FastBDT.h.

◆ m_nLevels

unsigned int m_nLevels = 3

Depth of tree.

Definition at line 64 of file FastBDT.h.

◆ m_nTrees

unsigned int m_nTrees = 200

Number of trees.

Definition at line 62 of file FastBDT.h.

◆ m_purityTransformation

bool m_purityTransformation = false

Activates purity transformation globally for all features.

Definition at line 71 of file FastBDT.h.

◆ m_randRatio

double m_randRatio = 0.5

Fraction of data to use in the stochastic training.

Definition at line 66 of file FastBDT.h.

◆ m_shrinkage

double m_shrinkage = 0.1

Shrinkage during the boosting step.

Definition at line 65 of file FastBDT.h.

◆ m_sPlot

bool m_sPlot = false

Activates sPlot sampling.

Definition at line 70 of file FastBDT.h.


The documentation for this class was generated from the following files: