51 const TString &methodTitle,
53 const TString &theOption) :
58 asfactor(
"as.factor"),
64 fType =
"C-classification";
93 fType =
"C-classification";
129 Error(
"Init",
"R's package e1071 can not be loaded.");
130 Log() << kFATAL <<
" R's package e1071 can not be loaded." 138 if (
Data()->GetNTrainingEvents() == 0)
Log() << kFATAL <<
"<Train> Data() has zero events" <<
Endl;
147 <<
" Type is " <<
fType 176 r[
"RSVMModel"] << Model;
177 r <<
"save(RSVMModel,file='" + path +
"')";
185 ‘scale’ is of length 1, the value is recycled as many times \ 186 as needed. Per default, data are scaled internally (both ‘x’\ 187 and ‘y’ variables) to zero mean and unit variance. The center \ 188 and scale values are returned and used for later predictions.");
190 regression machine, or for novelty detection. Depending of\ 191 whether ‘y’ is a factor or not, the default setting for\ 192 ‘type’ is ‘C-classification’ or ‘eps-regression’,\ 193 respectively, but may be overwritten by setting an explicit value.\ 195 - ‘C-classification’\ 196 - ‘nu-classification’\ 197 - ‘one-classification’ (for novelty detection)\ 201 consider changing some of the following parameters, depending on the kernel type.\ 203 polynomial: (gamma*u'*v + coef0)^degree\ 204 radial basis: exp(-gamma*|u-v|^2)\ 205 sigmoid: tanh(gamma*u'*v + coef0)");
207 DeclareOptionRef(
fGamma,
"Gamma",
"parameter needed for all kernels except ‘linear’ (default:1/(data dimension))");
208 DeclareOptionRef(
fCoef0,
"Coef0",
"parameter needed for kernels of type ‘polynomial’ and ‘sigmoid’ (default: 0)");
209 DeclareOptionRef(
fCost,
"Cost",
"cost of constraints violation (default: 1)-it is the ‘C’-constant of the regularization term in the Lagrange formulation.");
210 DeclareOptionRef(
fNu,
"Nu",
"parameter needed for ‘nu-classification’, ‘nu-regression’,and ‘one-classification’");
215 DeclareOptionRef(
fCross,
"Cross",
"if a integer value k>0 is specified, a k-fold cross validation on the training data is performed to assess the\ 216 quality of the model: the accuracy rate for classification and the Mean Squared Error for regression");
217 DeclareOptionRef(
fFitted,
"Fitted",
"logical indicating whether the fitted values should be computed and included in the model or not (default: ‘TRUE’)");
225 r[
"RMVA.RSVM.Type"] =
fType;
230 r[
"RMVA.RSVM.Cost"] =
fCost;
231 r[
"RMVA.RSVM.Nu"] =
fNu;
245 Log() << kINFO <<
"Testing Classification RSVM METHOD " <<
Endl;
259 for (
UInt_t i = 0; i < nvar; i++) {
267 mvaValue = values[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);
320 r <<
"v2 <- attr(result, \"probabilities\") ";
322 r[
"length(v2)"] >> probSize;
325 std::vector<Double_t> probValues = result.GetAttribute(
"probabilities");
327 assert(probValues.size() == 2*mvaValues.size());
328 for (
int i = 0; i <
nEvents; ++i)
331 mvaValues[i] = probValues[nEvents+i];
336 Log() << kINFO <<
" : Probabilities are not available. Use decision values instead !" <<
Endl;
338 std::vector<Double_t> probValues = result.GetAttribute(
"decision.values");
339 mvaValues = probValues;
347 Log() << kINFO <<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"Elapsed time for evaluation of " << nEvents <<
" events: " 363 r <<
"load('" + path +
"')";
365 r[
"RSVMModel"] >> Model;
380 Log() <<
"Decision Trees and Rule-Based Models " <<
Endl;
UInt_t GetNVariables() const
void SetCurrentEvent(Long64_t ievt) const
MsgLogger & Endl(MsgLogger &ml)
Singleton class for Global types used by TMVA.
std::vector< TString > GetListOfVariables() const
returns list of variables
OptionBase * DeclareOptionRef(T &ref, const TString &name, const TString &desc="")
ROOT::R::TRObject * fModel
UInt_t GetNVariables() const
access the number of variables through the datasetinfo
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
ROOT::R::TRFunctionImport asfactor
const TString & GetWeightFileDir() const
Long64_t GetNEvtBkgdTrain()
return number of background training events in dataset
ROOT::R::TRFunctionImport svm
static Bool_t IsModuleLoaded
const Event * GetEvent() const
void GetHelpMessage() const
TRObject GetAttribute(const TString name)
The R objects can to have associate attributes with this method you can added attribute to TRObject g...
void ReadStateFromFile()
Function to write options and weights to file.
Types::ETreeType GetCurrentType() const
DataSetInfo & DataInfo() const
ROOT::R::TRFunctionImport predict
Class that contains all the data information.
Bool_t Require(TString pkg)
Method to load an R's package.
TString GetElapsedTime(Bool_t Scientific=kTRUE)
returns pretty string with elapsed time
Int_t GetNcols()
Method to get the number of colunms.
This is a class to get ROOT's objects from R's objects
std::vector< std::string > fFactorTrain
const char * GetName() const
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
char * Form(const char *fmt,...)
const TString & GetMethodName() const
Double_t GetMvaValue(Double_t *errLower=0, Double_t *errUpper=0)
UInt_t GetNVariables() const
accessor to the number of variables
Float_t GetValue(UInt_t ivar) const
return value of i'th variable
Long64_t GetNEvtSigTrain()
return number of signal training events in dataset
Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
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
MethodRSVM(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
virtual void TestClassification()
initialization
Long64_t GetNEvents(Types::ETreeType type=Types::kMaxTreeType) const
Rcpp::internal::NamedPlaceHolder Label
Timing information for training and evaluation of MVA methods.
virtual void TestClassification()
initialization
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
Bool_t IsModelPersistence()