47 Bool_t MethodRXGB::IsModuleLoaded = ROOT::
R::TRInterface::Instance().Require("xgboost");
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"),
76 predict(
"predict",
"xgboost"),
78 xgbdmatrix(
"xgb.DMatrix"),
81 asfactor(
"as.factor"),
82 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;
270 TString path = GetWeightFileDir() +
"/RXGBModel.RData";
275 SEXP Model = xgbload(path);
ROOT::R::TRFunctionImport xgbdmatrix
const TString & GetWeightFileDir() 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)
const char * GetName() const
OptionBase * DeclareOptionRef(T &ref, const TString &name, const TString &desc="")
ROOT::R::TRObject * fModel
UInt_t GetNVariables() const
const TString & GetMethodName() const
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
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
void ReadStateFromFile()
Function to write options and weights to file.
void SetCurrentEvent(Long64_t ievt) const
Class that contains all the data information.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
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.
UInt_t GetNVariables() const
accessor to the number of variables
TString GetElapsedTime(Bool_t Scientific=kTRUE)
returns pretty string with elapsed time
virtual void MakeClass(const TString &classFileName=TString("")) const
create reader class for method (classification only at present)
This is a class to get ROOT's objects from R's objects
std::vector< std::string > fFactorTrain
ROOT::R::TRFunctionImport xgbsave
void GetHelpMessage() const
const Event * GetEvent() const
char * Form(const char *fmt,...)
ROOT::R::TRFunctionImport asmatrix
Types::ETreeType GetCurrentType() const
const Event * GetEvent() const
virtual void TestClassification()
initialization
Long64_t GetNEvents(Types::ETreeType type=Types::kMaxTreeType) const
static TRInterface & Instance()
static method to get an TRInterface instance reference
UInt_t GetNVariables() const
access the number of variables through the datasetinfo
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
DataSetInfo & DataInfo() const
MethodRXGB(const TString &jobName, const TString &methodTitle, DataSetInfo &theData, const TString &theOption="")
#define REGISTER_METHOD(CLASS)
for example
std::vector< Float_t > & GetValues()
ROOT::R::TRDataFrame fDfTrain
ROOT::R::TRFunctionImport predict
std::vector< TString > GetListOfVariables() const
returns list of variables
Rcpp::internal::NamedPlaceHolder Label
Double_t GetMvaValue(Double_t *errLower=0, Double_t *errUpper=0)
static Bool_t IsModuleLoaded
Timing information for training and evaluation of MVA methods.
virtual void TestClassification()
initialization
ROOT::R::TRFunctionImport xgbtrain
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()