51 const TString &methodTitle,
53 const TString &theOption) :
RMethodBase(jobName,
Types::kRXGB, methodTitle, dsi, theOption),
57 predict(
"predict",
"xgboost"),
59 xgbdmatrix(
"xgb.DMatrix"),
62 asfactor(
"as.factor"),
63 asmatrix(
"as.matrix"),
108 Error(
"Init",
"R's package xgboost can not be loaded.");
109 Log() << kFATAL <<
" R's package xgboost can not be loaded." 118 for (
UInt_t i = 0; i < size; i++) {
129 if (
Data()->GetNTrainingEvents() == 0)
Log() << kFATAL <<
"<Train> Data() has zero events" <<
Endl;
132 params[
"eta"] =
fEta;
156 DeclareOptionRef(
fEta,
"Eta",
"Step size shrinkage used in update to prevents overfitting. After each boosting step, we can directly get the weights of new features. and eta actually shrinks the feature weights to make the boosting process more conservative.");
168 Log() << kINFO <<
"Testing Classification RXGB METHOD " <<
Endl;
181 for (
UInt_t i = 0; i < nvar; i++) {
196 if (firstEvt > lastEvt || lastEvt > nEvents) lastEvt = nEvents;
197 if (firstEvt < 0) firstEvt = 0;
199 nEvents = lastEvt-firstEvt;
211 std::vector<std::vector<Float_t> > inputData(nvars);
212 for (
UInt_t i = 0; i < nvars; i++) {
213 inputData[i] = std::vector<Float_t>(nEvents);
216 for (
Int_t ievt=firstEvt; ievt<lastEvt; ievt++) {
220 for (
UInt_t i = 0; i < nvars; i++) {
221 inputData[i][ievt] = e->
GetValue(i);
228 for (
UInt_t i = 0; i < nvars; i++) {
234 std::vector<Double_t> mvaValues(nEvents);
236 mvaValues = pred.
As<std::vector<Double_t>>();
239 Log() << kINFO <<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"Elapsed time for evaluation of " << nEvents <<
" events: " 256 Log() <<
"Decision Trees and Rule-Based Models " <<
Endl;
ROOT::R::TRFunctionImport xgbdmatrix
UInt_t GetNVariables() const
void SetCurrentEvent(Long64_t ievt) const
MsgLogger & Endl(MsgLogger &ml)
Singleton class for Global types used by TMVA.
Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
std::vector< TString > GetListOfVariables() const
returns list of variables
OptionBase * DeclareOptionRef(T &ref, const TString &name, const TString &desc="")
UInt_t GetNVariables() const
access the number of variables through the datasetinfo
ROOT::R::TRFunctionImport asfactor
ROOT::R::TRObject * fModel
const TString & GetWeightFileDir() const
virtual std::vector< Double_t > GetMvaValues(Long64_t firstEvt=0, Long64_t lastEvt=-1, Bool_t logProgress=false)
get all the MVA values for the events of the current Data type
const Event * GetEvent() const
void ReadStateFromFile()
Function to write options and weights to file.
Types::ETreeType GetCurrentType() const
DataSetInfo & DataInfo() const
Class that contains all the data information.
T As()
Some datatypes of ROOT or c++ can be wrapped in to a TRObject, this method lets you unwrap those data...
Bool_t Require(TString pkg)
Method to load an R's package.
TString GetElapsedTime(Bool_t Scientific=kTRUE)
returns pretty string with elapsed time
This is a class to get ROOT's objects from R's objects
std::vector< std::string > fFactorTrain
ROOT::R::TRFunctionImport xgbsave
const char * GetName() const
ROOT::R::TRFunctionImport xgbload
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
char * Form(const char *fmt,...)
const TString & GetMethodName() const
ROOT::R::TRFunctionImport asmatrix
UInt_t GetNVariables() const
accessor to the number of variables
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
virtual void TestClassification()
initialization
static TRInterface & Instance()
static method to get an TRInterface instance reference
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
MethodRXGB(const TString &jobName, const TString &methodTitle, DataSetInfo &theData, const TString &theOption="")
#define REGISTER_METHOD(CLASS)
for example
Abstract ClassifierFactory template that handles arbitrary types.
std::vector< Float_t > & GetValues()
ROOT::R::TRDataFrame fDfTrain
ROOT::R::TRFunctionImport predict
Long64_t GetNEvents(Types::ETreeType type=Types::kMaxTreeType) const
Rcpp::internal::NamedPlaceHolder Label
virtual void MakeClass(const TString &classFileName=TString("")) const
create reader class for method (classification only at present)
Double_t GetMvaValue(Double_t *errLower=0, Double_t *errUpper=0)
static Bool_t IsModuleLoaded
void GetHelpMessage() const
Timing information for training and evaluation of MVA methods.
virtual void TestClassification()
initialization
ROOT::R::TRFunctionImport xgbtrain
const Event * GetEvent() const
void NoErrorCalc(Double_t *const err, Double_t *const errUpper)
This is a class to create DataFrames from ROOT to R
std::vector< UInt_t > fFactorNumeric
Bool_t IsModelPersistence()