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;
131 ROOT::R::TRDataFrame params;
132 params[
"eta"] =
fEta;
141 fModel =
new ROOT::R::TRObject(Model);
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;
180 ROOT::R::TRDataFrame fDfEvent;
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);
227 ROOT::R::TRDataFrame evtData;
228 for (
UInt_t i = 0; i < nvars; i++) {
234 std::vector<Double_t> mvaValues(nEvents);
236 mvaValues = pred.As<std::vector<Double_t>>();
256 Log() <<
"Decision Trees and Rule-Based Models " <<
Endl;
269 ROOT::R::TRInterface::Instance().Require(
"RXGB");
276 fModel =
new ROOT::R::TRObject(Model);
ROOT::R::TRFunctionImport xgbdmatrix
UInt_t GetNVariables() const
void SetCurrentEvent(Long64_t ievt) const
MsgLogger & Endl(MsgLogger &ml)
Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
RooCmdArg Label(const char *str)
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
TString GetElapsedTime(Bool_t Scientific=kTRUE)
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
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
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
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
virtual void TestClassification()
initialization
ROOT::R::TRFunctionImport xgbtrain
const Event * GetEvent() const
void NoErrorCalc(Double_t *const err, Double_t *const errUpper)
std::vector< UInt_t > fFactorNumeric
Bool_t IsModelPersistence()