Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RMethodBase.cxx
Go to the documentation of this file.
1// @(#)root/tmva/rmva $Id$
2// Author: Omar Zapata,Lorenzo Moneta, Sergei Gleyzer 2015
3
4
5/**********************************************************************************
6 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
7 * Package: TMVA *
8 * Class : RMethodBase *
9 * *
10 * Description: *
11 * Virtual base class for all MVA method based on ROOTR *
12 * *
13 **********************************************************************************/
14
15#include<TMVA/RMethodBase.h>
16#include <TMVA/DataSetInfo.h>
17#include<TApplication.h>
18using namespace TMVA;
19
20
21//_______________________________________________________________________
31
32//_______________________________________________________________________
40
41//_______________________________________________________________________
43{
44 ///////////////////////////
45 //Loading Training Data //
46 ///////////////////////////
47 const UInt_t nvar = DataInfo().GetNVariables();
48
50
51 //array of columns for every var to create a dataframe for training
52 std::vector<std::vector<Float_t> > fArrayTrain(nvar);
53// Data()->SetCurrentEvent(1);
54// Data()->SetCurrentType(Types::ETreeType::kTraining);
55
57 for (UInt_t j = 0; j < ntrains; j++) {
59// const Event *ev=Data()->GetEvent( j );
60 //creating array with class type(signal or background) for factor required
61 if (ev->GetClass() == Types::kSignal) fFactorTrain.push_back("signal");
62 else fFactorTrain.push_back("background");
63
64 fWeightTrain[j] = ev->GetWeight();
65
66 //filling vector of columns for training
67 for (UInt_t i = 0; i < nvar; i++) {
68 fArrayTrain[i].push_back(ev->GetValue(i));
69 }
70
71 }
72 for (UInt_t i = 0; i < nvar; i++) {
74 }
75 ////////////////////////
76 //Loading Test Data //
77 ////////////////////////
78
79 const UInt_t ntests = Data()->GetNTestEvents();
81
82 //array of columns for every var to create a dataframe for testing
83 std::vector<std::vector<Float_t> > fArrayTest(nvar);
84 //array of columns for every spectator to create a dataframe for testing
85 std::vector<std::vector<Float_t> > fArraySpectators(nvar);
87// Data()->SetCurrentType(Types::ETreeType::kTesting);
88 for (UInt_t j = 0; j < ntests; j++) {
90// const Event *ev=Data()->GetEvent(j);
91 //creating array with class type(signal or background) for factor required
92 if (ev->GetClass() == Types::kSignal) fFactorTest.push_back("signal");
93 else fFactorTest.push_back("background");
94
95 fWeightTest[j] = ev->GetWeight();
96
97 for (UInt_t i = 0; i < nvar; i++) {
98 fArrayTest[i].push_back(ev->GetValue(i));
99 }
100 for (UInt_t i = 0; i < nspectators; i++) {
101 fArraySpectators[i].push_back(ev->GetSpectator(i));
102 }
103 }
104 for (UInt_t i = 0; i < nvar; i++) {
105 fDfTest[DataInfo().GetListOfVariables()[i].Data()] = fArrayTest[i];
106 }
107 for (UInt_t i = 0; i < nspectators; i++) {
109 }
110
111}
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
ROOT R was implemented using the R Project library and the modules Rcpp and RInside
Class that contains all the data information.
Definition DataSetInfo.h:62
UInt_t GetNVariables() const
UInt_t GetNSpectators(bool all=kTRUE) const
std::vector< TString > GetListOfVariables() const
returns list of variables
VariableInfo & GetSpectatorInfo(Int_t i)
Long64_t GetNTestEvents() const
Definition DataSet.h:69
const Event * GetEvent() const
returns event without transformations
Definition DataSet.cxx:202
Long64_t GetNTrainingEvents() const
Definition DataSet.h:68
Virtual base Class for all MVA method.
Definition MethodBase.h:111
DataSetInfo & DataInfo() const
Definition MethodBase.h:410
DataSet * Data() const
Definition MethodBase.h:409
std::vector< std::string > fFactorTrain
Definition RMethodBase.h:95
ROOT::R::TRDataFrame fDfTrain
Definition RMethodBase.h:91
RMethodBase(const TString &jobName, Types::EMVA methodType, const TString &methodTitle, DataSetInfo &dsi, const TString &theOption="", ROOT::R::TRInterface &_r=ROOT::R::TRInterface::Instance())
TVectorD fWeightTrain
Definition RMethodBase.h:93
ROOT::R::TRDataFrame fDfTest
Definition RMethodBase.h:92
TVectorD fWeightTest
Definition RMethodBase.h:94
std::vector< std::string > fFactorTest
Definition RMethodBase.h:96
ROOT::R::TRDataFrame fDfSpectators
Definition RMethodBase.h:97
@ kSignal
Never change this number - it is elsewhere assumed to be zero !
Definition Types.h:135
@ kTraining
Definition Types.h:143
const TString & GetLabel() const
Basic string class.
Definition TString.h:138
TVectorT< Element > & ResizeTo(Int_t lwb, Int_t upb)
Resize the vector to [lwb:upb] .
Definition TVectorT.cxx:293
create variable transformations