50MethodRXGB::MethodRXGB(
const TString &jobName,
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++) {
219 assert(nvars ==
e->GetNVariables());
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;
275 SEXP Model = xgbload(path);
#define REGISTER_METHOD(CLASS)
for example
char * Form(const char *fmt,...)
This is a class to create DataFrames from ROOT to R.
static TRInterface & Instance()
static method to get an TRInterface instance reference
Bool_t Require(TString pkg)
Method to load an R's package.
This is a class to get ROOT's objects from R's objects.
T As()
Some datatypes of ROOT or c++ can be wrapped in to a TRObject, this method lets you unwrap those data...
OptionBase * DeclareOptionRef(T &ref, const TString &name, const TString &desc="")
Class that contains all the data information.
UInt_t GetNVariables() const
std::vector< TString > GetListOfVariables() const
returns list of variables
const Event * GetEvent() const
Types::ETreeType GetCurrentType() const
Long64_t GetNEvents(Types::ETreeType type=Types::kMaxTreeType) const
UInt_t GetNVariables() const
access the number of variables through the datasetinfo
void SetCurrentEvent(Long64_t ievt) const
std::vector< Float_t > & GetValues()
const char * GetName() const
const TString & GetWeightFileDir() const
const TString & GetMethodName() const
const Event * GetEvent() const
DataSetInfo & DataInfo() const
virtual void TestClassification()
initialization
void ReadStateFromFile()
Function to write options and weights to file.
Bool_t IsModelPersistence()
void NoErrorCalc(Double_t *const err, Double_t *const errUpper)
std::vector< UInt_t > fFactorNumeric
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 GetHelpMessage() const
ROOT::R::TRFunctionImport xgbtrain
MethodRXGB(const TString &jobName, const TString &methodTitle, DataSetInfo &theData, const TString &theOption="")
static Bool_t IsModuleLoaded
ROOT::R::TRFunctionImport asmatrix
virtual void TestClassification()
initialization
Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
virtual void MakeClass(const TString &classFileName=TString("")) const
create reader class for method (classification only at present)
ROOT::R::TRFunctionImport xgbsave
ROOT::R::TRObject * fModel
ROOT::R::TRFunctionImport xgbdmatrix
ROOT::R::TRFunctionImport predict
Double_t GetMvaValue(Double_t *errLower=0, Double_t *errUpper=0)
std::vector< std::string > fFactorTrain
ROOT::R::TRDataFrame fDfTrain
Timing information for training and evaluation of MVA methods.
TString GetElapsedTime(Bool_t Scientific=kTRUE)
returns pretty string with elapsed time
Singleton class for Global types used by TMVA.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
std::string GetName(const std::string &scope_name)
Rcpp::internal::NamedPlaceHolder Label
create variable transformations
MsgLogger & Endl(MsgLogger &ml)