Belle II Software light-2406-ragdoll
TrivialExpert Class Reference

Expert for the Trivial MVA method. More...

#include <Trivial.h>

Inheritance diagram for TrivialExpert:
Collaboration diagram for TrivialExpert:

Public Member Functions

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

Protected Attributes

GeneralOptions m_general_options
 General options loaded from the weightfile.
 

Private Attributes

TrivialOptions m_specific_options
 Method specific options.
 

Detailed Description

Expert for the Trivial MVA method.

Used for debugging and testing

Definition at line 86 of file Trivial.h.

Member Function Documentation

◆ apply()

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

Apply this expert onto a dataset.

Parameters
test_datadataset

Implements Expert.

Definition at line 83 of file Trivial.cc.

84 {
86 if (m_general_options.m_variables.size() != 1) {
87 B2ERROR("Trivial method in passthrough mode requires exactly 1 input variables. Found " << m_general_options.m_variables.size());
88 }
89 }
90 std::vector<float> probabilities(test_data.getNumberOfEvents());
91 for (unsigned int iEvent = 0; iEvent < test_data.getNumberOfEvents(); ++iEvent) {
92 test_data.loadEvent(iEvent);
94 probabilities[iEvent] = test_data.m_input[0];
95 } else {
96 probabilities[iEvent] = m_specific_options.m_output;
97 }
98 }
99 return probabilities;
100 }
GeneralOptions m_general_options
General options loaded from the weightfile.
Definition: Expert.h:70
std::vector< std::string > m_variables
Vector of all variables (branch names) used in the training.
Definition: Options.h:86
TrivialOptions m_specific_options
Method specific options.
Definition: Trivial.h:108
double m_output
Output of the trivial method.
Definition: Trivial.h:53
bool m_passthrough
Flag for passthrough setting.
Definition: Trivial.h:55

◆ applyMulticlass()

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

Apply this expert onto a dataset.

Parameters
test_datadataset

Reimplemented from Expert.

Definition at line 102 of file Trivial.cc.

103 {
105 B2ERROR("The number of classes declared in the general options do not match the number of outputs declared in the specific options for the Trivial expert");
106 }
107
110 B2ERROR("Trivial method in passthrough mode requires either exactly one input variable or one per class, matching the number of classes declared in the general options. Found "
112 }
113 }
114
115 std::vector<std::vector<float>> probabilities(test_data.getNumberOfEvents(), std::vector<float>(m_general_options.m_nClasses));
116 for (unsigned int iEvent = 0; iEvent < test_data.getNumberOfEvents(); ++iEvent) {
117 test_data.loadEvent(iEvent);
118 for (unsigned int iClass = 0; iClass < m_general_options.m_nClasses; ++iClass) {
120 if (m_general_options.m_variables.size() == 1) {
121 probabilities[iEvent][iClass] = test_data.m_input[0];
122 } else {
123 probabilities[iEvent][iClass] = test_data.m_input[iClass];
124 }
125 } else {
126 probabilities[iEvent][iClass] = m_specific_options.m_multiple_output.at(iClass);
127 }
128 }
129 }
130 return probabilities;
131 }
unsigned int m_nClasses
Number of classes in a classification problem.
Definition: Options.h:89
std::vector< double > m_multiple_output
Output of the trivial method.
Definition: Trivial.h:54

◆ load()

void load ( Weightfile weightfile)
overridevirtual

Load the expert from a Weightfile.

Parameters
weightfilecontaining all information necessary to build the expert

Implements Expert.

Definition at line 77 of file Trivial.cc.

78 {
79 weightfile.getOptions(m_general_options);
80 weightfile.getOptions(m_specific_options);
81 }

Member Data Documentation

◆ 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

TrivialOptions m_specific_options
private

Method specific options.

Definition at line 108 of file Trivial.h.


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