Belle II Software light-2406-ragdoll
PDFExpert Class Reference

Expert for the PDF MVA method. More...

#include <PDF.h>

Inheritance diagram for PDFExpert:
Collaboration diagram for PDFExpert:

Public Member Functions

virtual void load (Weightfile &weightfile) override
 Load the PDF expert from a Weightfile.
 
virtual std::vector< float > apply (Dataset &test_data) const override
 Apply PDF expert onto a dataset.
 
virtual std::vector< std::vector< float > > applyMulticlass (Dataset &test_data) const
 Apply this m_expert onto a dataset.
 

Protected Attributes

GeneralOptions m_general_options
 General options loaded from the weightfile.
 

Private Attributes

PDFOptions m_specific_options
 Specific options of the PDF method.
 
Binning m_binning
 used binning
 
std::vector< double > m_value
 value returned by expert for each bin
 

Detailed Description

Expert for the PDF MVA method.

Definition at line 86 of file PDF.h.

Member Function Documentation

◆ apply()

std::vector< float > apply ( Dataset test_data) const
overridevirtual

Apply PDF expert onto a dataset.

Parameters
test_datadataset

Implements Expert.

Definition at line 143 of file PDF.cc.

144 {
145 std::vector<float> probabilities(test_data.getNumberOfEvents(), 0);
146 for (unsigned int iEvent = 0; iEvent < test_data.getNumberOfEvents(); ++iEvent) {
147 test_data.loadEvent(iEvent);
148 unsigned int bin = m_binning.getBin(test_data.m_input[0]);
149 probabilities[iEvent] = m_value[bin];
150 }
151 return probabilities;
152 }
unsigned int getBin(float datapoint) const
Gets the bin corresponding to the given datapoint.
Definition: Binning.cc:34
Binning m_binning
used binning
Definition: PDF.h:103
std::vector< double > m_value
value returned by expert for each bin
Definition: PDF.h:104

◆ applyMulticlass()

virtual std::vector< std::vector< float > > applyMulticlass ( Dataset test_data) const
inlinevirtualinherited

Apply this m_expert onto a dataset.

Multiclass mode. Not pure virtual, since not all derived classes to re-implement this.

Parameters
test_datadataset.
Returns
vector of size N=test_data.getNumberOfEvents() with N=m_classes.size() scores for each event in the dataset.

Reimplemented in PythonExpert, TMVAExpertMulticlass, and TrivialExpert.

Definition at line 56 of file Expert.h.

57 {
58
59 B2ERROR("Attempted to call applyMulticlass() of the abstract base class MVA::Expert. All methods that support multiclass classification should override this definition.");
60 (void) test_data;
61
62 return std::vector<std::vector<float>>();
63 };

◆ load()

void load ( Weightfile weightfile)
overridevirtual

Load the PDF expert from a Weightfile.

Parameters
weightfilecontaining all information necessary to build the expert

Implements Expert.

Definition at line 118 of file PDF.cc.

119 {
120
121 std::string custom_weightfile = weightfile.generateFileName();
122 weightfile.getFile("PDF_Weightfile", custom_weightfile);
123 std::fstream file(custom_weightfile, std::ios_base::in);
124
125 unsigned int nBins = 0;
126 file >> nBins;
127 m_value.resize(nBins, 0);
128
129 std::vector<float> boundaries(nBins + 1, 0);
130
131 for (unsigned int iBin = 0; iBin < nBins; ++iBin) {
132 file >> m_value[iBin] >> boundaries[iBin];
133 }
134 file >> boundaries[nBins];
135
136 m_binning.m_boundaries = boundaries;
137
138 file.close();
139
140 weightfile.getOptions(m_specific_options);
141 }
std::vector< float > m_boundaries
Boundaries of data distribution, including minimum and maximum value as first and last boundary.
Definition: Binning.h:61
PDFOptions m_specific_options
Specific options of the PDF method.
Definition: PDF.h:102

Member Data Documentation

◆ m_binning

Binning m_binning
private

used binning

Definition at line 103 of file PDF.h.

◆ m_general_options

GeneralOptions m_general_options
protectedinherited

General options loaded from the weightfile.

Definition at line 70 of file Expert.h.

◆ m_specific_options

PDFOptions m_specific_options
private

Specific options of the PDF method.

Definition at line 102 of file PDF.h.

◆ m_value

std::vector<double> m_value
private

value returned by expert for each bin

Definition at line 104 of file PDF.h.


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