Belle II Software development
FastBDT.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10#ifndef INCLUDE_GUARD_BELLE2_MVA_FASTBDT_HEADER
11#define INCLUDE_GUARD_BELLE2_MVA_FASTBDT_HEADER
12
13#include <mva/interface/Options.h>
14#include <mva/interface/Teacher.h>
15#include <mva/interface/Expert.h>
16
17#include <FastBDT.h>
18#include <FastBDT_IO.h>
19#include <Classifier.h>
20
21namespace Belle2 {
26 namespace MVA {
27
28
32 bool isValidSignal(const std::vector<bool>& Signals);
33
38
39 public:
44 virtual void load(const boost::property_tree::ptree& pt) override;
45
50 virtual void save(boost::property_tree::ptree& pt) const override;
51
55 virtual po::options_description getDescription() override;
56
60 virtual std::string getMethod() const override { return "FastBDT"; }
61
62 unsigned int m_nTrees = 200;
63 unsigned int m_nCuts = 8;
64 unsigned int m_nLevels = 3;
65 double m_shrinkage = 0.1;
66 double m_randRatio = 0.5;
67 std::vector<unsigned int>
69 double m_flatnessLoss = -1.0;
70 bool m_sPlot = false;
72 std::vector<bool>
74 };
75
76
80 class FastBDTTeacher : public Teacher {
81
82 public:
88 FastBDTTeacher(const GeneralOptions& general_options, const FastBDTOptions& specific_options);
89
94 virtual Weightfile train(Dataset& training_data) const override;
95
96 private:
98 };
99
100
104 class FastBDTExpert : public MVA::Expert {
105
106 public:
111 virtual void load(Weightfile& weightfile) override;
112
117 virtual std::vector<float> apply(Dataset& test_data) const override;
118
119 private:
122 FastBDT::Classifier m_classifier;
123 FastBDT::Forest<float> m_expert_forest;
124 };
125
126 }
128}
129#endif
Abstract base class of all Datasets given to the MVA interface The current event can always be access...
Definition: Dataset.h:33
Abstract base class of all Expert Each MVA library has its own implementation of this class,...
Definition: Expert.h:31
Expert for the FastBDT MVA method.
Definition: FastBDT.h:104
FastBDT::Forest< float > m_expert_forest
Forest Expert -> used in case of no purity transformation.
Definition: FastBDT.h:123
FastBDT::Classifier m_classifier
Simplified FastBDT interface: classifier combines preprocessing and forest.
Definition: FastBDT.h:122
virtual std::vector< float > apply(Dataset &test_data) const override
Apply this expert onto a dataset.
Definition: FastBDT.cc:251
bool m_use_simplified_interface
Use the simplified FastBDT interface of version 4.
Definition: FastBDT.h:121
virtual void load(Weightfile &weightfile) override
Load the expert from a Weightfile.
Definition: FastBDT.cc:192
FastBDTOptions m_specific_options
Method specific options.
Definition: FastBDT.h:120
Options for the FANN MVA method.
Definition: FastBDT.h:37
virtual std::string getMethod() const override
Return method name.
Definition: FastBDT.h:60
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
virtual po::options_description getDescription() override
Returns a program options description for all available options.
Definition: FastBDT.cc:89
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
virtual void load(const boost::property_tree::ptree &pt) override
Load mechanism to load Options from a xml tree.
Definition: FastBDT.cc:31
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
virtual void save(boost::property_tree::ptree &pt) const override
Save mechanism to store Options in a xml tree.
Definition: FastBDT.cc:68
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
Teacher for the FastBDT MVA method.
Definition: FastBDT.h:80
FastBDTOptions m_specific_options
Method specific options.
Definition: FastBDT.h:97
virtual Weightfile train(Dataset &training_data) const override
Train a mva method using the given dataset returning a Weightfile.
Definition: FastBDT.cc:121
General options which are shared by all MVA trainings.
Definition: Options.h:62
Specific Options, all method Options have to inherit from this class.
Definition: Options.h:98
Abstract base class of all Teachers Each MVA library has its own implementation of this class,...
Definition: Teacher.h:29
The Weightfile class serializes all information about a training into an xml tree.
Definition: Weightfile.h:38
Abstract base class for different kinds of events.