Belle II Software  release-08-01-10
RegressionTeacher< BaseClassifierTeacher, RegressionClassifierOptions > Class Template Reference

Core class for the training of regression methods based on binary classifiers. More...

#include <Regression.h>

Inheritance diagram for RegressionTeacher< BaseClassifierTeacher, RegressionClassifierOptions >:
Collaboration diagram for RegressionTeacher< BaseClassifierTeacher, RegressionClassifierOptions >:

Public Member Functions

 RegressionTeacher (const GeneralOptions &general_options, const RegressionClassifierOptions &specific_options)
 Create a new teacher out of the general and the regression method specific options.
 
Weightfile train (Dataset &training_data) const override
 Call the train function. More...
 

Protected Attributes

GeneralOptions m_general_options
 GeneralOptions containing all shared options.
 

Private Attributes

RegressionClassifierOptions m_specific_options
 The method specific options.
 
BaseClassifierTeacher m_baseClassifierTeacher
 The teacher to use for training.
 

Detailed Description

template<class BaseClassifierTeacher, class RegressionClassifierOptions>
class Belle2::MVA::RegressionTeacher< BaseClassifierTeacher, RegressionClassifierOptions >

Core class for the training of regression methods based on binary classifiers.

The idea is as follows:

  • If you want to solve a regression task, you need to make sure your target is between 0 and 1 and is more or less equally distributed (this is your task)
  • The teacher will then train N binary classifiers, where N is given by the maximal bin number in the options.
  • Each binary classifier is trained on the same data, but as a (binary) target is using

    s >= (1/number of bins) * (bin number)

    for every bin in [1, number of bins). This means, the first method is able to decide if a target value is very low or not, the second if it is medium low or not ... and the last if it is very high or not. The expert answer to a new data sample is the averaged output of all classifiers, which is very high, if all classifiers think it has a high value (then the target value is probably high) and very small, if non of them thinks the target value is high.

The class is very generic and can be used with every binary classifier.

Template Parameters
BaseClassifierTeacherThe teacher of the base binary classifier
RegressionClassifierOptionsThe options of the classifier (probably inheriting from RegressionOptions)

Definition at line 139 of file Regression.h.

Member Function Documentation

◆ train()

Belle2::MVA::Weightfile train ( Dataset training_data) const
overridevirtual

Call the train function.

For each bin number in [1, number of bins) train a new classifier on the target

s >= (1/number of bins) * (bin number)

where s is the target variable of the dataset. By this, we end up with (number of bins) classifier, each trained on the same data but with different targets.

Implements Teacher.

Definition at line 245 of file Regression.h.

247 {
248  Weightfile weightfile;
249  weightfile.addOptions(m_general_options);
250  weightfile.addOptions(m_specific_options);
251 
252  for (unsigned int binNumber = 1; binNumber < m_specific_options.getMaximalBinNumber(); binNumber++) {
253  RegressionDataSet specificDataSet(m_general_options, &training_data,
254  1.0 / m_specific_options.getMaximalBinNumber() * binNumber);
255  Weightfile specificWeightFile = m_baseClassifierTeacher.train(specificDataSet);
256 
257  std::string file = weightfile.generateFileName();
258  Weightfile::saveToXMLFile(specificWeightFile, file);
259  weightfile.addFile("BaseClassifier_WeightFile_" + std::to_string(binNumber), file);
260  }
261  return weightfile;
262 }
BaseClassifierTeacher m_baseClassifierTeacher
The teacher to use for training.
Definition: Regression.h:161
RegressionClassifierOptions m_specific_options
The method specific options.
Definition: Regression.h:159
GeneralOptions m_general_options
GeneralOptions containing all shared options.
Definition: Teacher.h:49
static void saveToXMLFile(Weightfile &weightfile, const std::string &filename)
Static function which saves a Weightfile to a XML file.
Definition: Weightfile.cc:175

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