48 Bool_t MethodRSNNS::IsModuleLoaded = ROOT::
R::TRInterface::Instance().Require("RSNNS");
52 const TString &methodTitle,
54 const TString &theOption) :
59 asfactor("
as.factor"),
62 fNetType = methodTitle;
63 if (fNetType !=
"RMLP") {
64 Log() << kFATAL <<
" Unknow Method" + fNetType
74 fInitFunc =
"Randomize_Weights";
75 fInitFuncParams =
"c(-0.3,0.3)";
77 fLearnFunc =
"Std_Backpropagation";
78 fLearnFuncParams =
"c(0.2,0)";
80 fUpdateFunc =
"Topological_Order";
81 fUpdateFuncParams =
"c(0)";
83 fHiddenActFunc =
"Act_Logistic";
84 fShufflePatterns =
kTRUE;
87 fPruneFuncParams =
"NULL";
97 asfactor(
"as.factor"),
148 Error(
"Init",
"R's package RSNNS can not be loaded.");
149 Log() << kFATAL <<
" R's package RSNNS can not be loaded."
158 for (
UInt_t i = 0; i < size; i++) {
166 if (
Data()->GetNTrainingEvents() == 0)
Log() << kFATAL <<
"<Train> Data() has zero events" <<
Endl;
184 ROOT::R::Label[
"libOut"] =
fLinOut,
185 ROOT::R::Label[
"pruneFunc"] = PruneFunc,
195 r[
"RMLPModel"] << Model;
196 r <<
"save(RMLPModel,file='" + path +
"')";
224 other functions, these have to be given in a named list. See\
225 the pruning demos for further explanation.the update function to use");
233 Log() << kERROR <<
" fMaxit <=0... that does not work !! "
234 <<
" I set it to 50 .. just so that the program does not crash"
246 Log() << kINFO <<
"Testing Classification " <<
fNetType <<
" METHOD " <<
Endl;
260 for (
UInt_t i = 0; i < nvar; i++) {
267 mvaValue = result[0];
276 if (firstEvt > lastEvt || lastEvt > nEvents) lastEvt =
nEvents;
277 if (firstEvt < 0) firstEvt = 0;
279 nEvents = lastEvt-firstEvt;
291 std::vector<std::vector<Float_t> > inputData(nvars);
292 for (
UInt_t i = 0; i < nvars; i++) {
293 inputData[i] = std::vector<Float_t>(
nEvents);
296 for (
Int_t ievt=firstEvt; ievt<lastEvt; ievt++) {
300 for (
UInt_t i = 0; i < nvars; i++) {
301 inputData[i][ievt] = e->
GetValue(i);
308 for (
UInt_t i = 0; i < nvars; i++) {
314 std::vector<Double_t> mvaValues(nEvents);
317 mvaValues = result.
As<std::vector<Double_t>>();
322 Log() << kINFO <<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"Elapsed time for evaluation of " << nEvents <<
" events: "
335 TString path = GetWeightFileDir() +
"/RMLPModel.RData";
339 r <<
"load('" + path +
"')";
341 r[
"RMLPModel"] >> Model;
357 Log() <<
"Decision Trees and Rule-Based Models " <<
Endl;
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
MsgLogger & Endl(MsgLogger &ml)
Singleton class for Global types used by TMVA.
void GetHelpMessage() const
const char * GetName() const
OptionBase * DeclareOptionRef(T &ref, const TString &name, const TString &desc="")
ROOT::R::TRFunctionImport predict
std::vector< UInt_t > fFactorNumeric
ROOT::R::TRObject * fModel
UInt_t GetNVariables() const
Double_t GetMvaValue(Double_t *errLower=0, Double_t *errUpper=0)
virtual void TestClassification()
initialization
const TString & GetMethodName() const
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
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.
TString fUpdateFuncParams
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
This is a class to get ROOT's objects from R's objects
std::vector< std::string > fFactorTrain
const Event * GetEvent() const
char * Form(const char *fmt,...)
ROOT::R::TRFunctionImport mlp
Types::ETreeType GetCurrentType() const
const Event * GetEvent() const
MethodRSNNS(const TString &jobName, const TString &methodTitle, DataSetInfo &theData, const TString &theOption="")
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
Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
#define REGISTER_METHOD(CLASS)
for example
std::vector< Float_t > & GetValues()
ROOT::R::TRDataFrame fDfTrain
std::vector< TString > GetListOfVariables() const
returns list of variables
Rcpp::internal::NamedPlaceHolder Label
Int_t Eval(const TString &code, TRObject &ans)
Method to eval R code and you get the result in a reference to TRObject.
static Bool_t IsModuleLoaded
Timing information for training and evaluation of MVA methods.
virtual void TestClassification()
initialization
void NoErrorCalc(Double_t *const err, Double_t *const errUpper)
This is a class to create DataFrames from ROOT to R
Bool_t IsModelPersistence()