63 fType =
"C-classification";
92 fType =
"C-classification";
128 Error(
"Init",
"R's package e1071 can not be loaded.");
129 Log() << kFATAL <<
" R's package e1071 can not be loaded."
137 if (
Data()->GetNTrainingEvents() == 0)
Log() << kFATAL <<
"<Train> Data() has zero events" <<
Endl;
146 <<
" Type is " <<
fType
175 r[
"RSVMModel"] << Model;
176 r <<
"save(RSVMModel,file='" + path +
"')";
184 ‘scale’ is of length 1, the value is recycled as many times \
185 as needed. Per default, data are scaled internally (both ‘x’\
186 and ‘y’ variables) to zero mean and unit variance. The center \
187 and scale values are returned and used for later predictions.");
189 regression machine, or for novelty detection. Depending of\
190 whether ‘y’ is a factor or not, the default setting for\
191 ‘type’ is ‘C-classification’ or ‘eps-regression’,\
192 respectively, but may be overwritten by setting an explicit value.\
194 - ‘C-classification’\
195 - ‘nu-classification’\
196 - ‘one-classification’ (for novelty detection)\
200 consider changing some of the following parameters, depending on the kernel type.\
202 polynomial: (gamma*u'*v + coef0)^degree\
203 radial basis: exp(-gamma*|u-v|^2)\
204 sigmoid: tanh(gamma*u'*v + coef0)");
206 DeclareOptionRef(
fGamma,
"Gamma",
"parameter needed for all kernels except ‘linear’ (default:1/(data dimension))");
207 DeclareOptionRef(
fCoef0,
"Coef0",
"parameter needed for kernels of type ‘polynomial’ and ‘sigmoid’ (default: 0)");
208 DeclareOptionRef(
fCost,
"Cost",
"cost of constraints violation (default: 1)-it is the ‘C’-constant of the regularization term in the Lagrange formulation.");
209 DeclareOptionRef(
fNu,
"Nu",
"parameter needed for ‘nu-classification’, ‘nu-regression’,and ‘one-classification’");
214 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 quality of the model: the accuracy rate for classification and the Mean Squared Error for regression");
216 DeclareOptionRef(
fFitted,
"Fitted",
"logical indicating whether the fitted values should be computed and included in the model or not (default: ‘TRUE’)");
224 r[
"RMVA.RSVM.Type"] =
fType;
229 r[
"RMVA.RSVM.Cost"] =
fCost;
230 r[
"RMVA.RSVM.Nu"] =
fNu;
244 Log() << kINFO <<
"Testing Classification RSVM METHOD " <<
Endl;
258 for (UInt_t i = 0; i < nvar; i++) {
266 mvaValue = values[0];
275 if (firstEvt > lastEvt || lastEvt > nEvents) lastEvt = nEvents;
276 if (firstEvt < 0) firstEvt = 0;
278 nEvents = lastEvt-firstEvt;
290 std::vector<std::vector<Float_t> > inputData(nvars);
291 for (UInt_t i = 0; i < nvars; i++) {
292 inputData[i] = std::vector<Float_t>(nEvents);
295 for (
Int_t ievt=firstEvt; ievt<lastEvt; ievt++) {
298 assert(nvars ==
e->GetNVariables());
299 for (UInt_t i = 0; i < nvars; i++) {
300 inputData[i][ievt] =
e->GetValue(i);
307 for (UInt_t i = 0; i < nvars; i++) {
313 std::vector<Double_t> mvaValues(nEvents);
318 r[
"result"] << result;
319 r <<
"v2 <- attr(result, \"probabilities\") ";
321 r[
"length(v2)"] >> probSize;
324 std::vector<Double_t> probValues = result.
GetAttribute(
"probabilities");
326 assert(probValues.size() == 2*mvaValues.size());
327 for (
int i = 0; i < nEvents; ++i)
330 mvaValues[i] = probValues[nEvents+i];
335 Log() << kINFO <<
" : Probabilities are not available. Use decision values instead !" <<
Endl;
337 std::vector<Double_t> probValues = result.
GetAttribute(
"decision.values");
338 mvaValues = probValues;
346 Log() << kINFO <<
Form(
"Dataset[%s] : ",
DataInfo().
GetName())<<
"Elapsed time for evaluation of " << nEvents <<
" events: "
362 r <<
"load('" + path +
"')";
364 r[
"RSVMModel"] >> Model;
379 Log() <<
"Decision Trees and Rule-Based Models " <<
Endl;
#define REGISTER_METHOD(CLASS)
for example
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
TVectorT< Double_t > TVectorD
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.
TRObject GetAttribute(const TString name)
The R objects can to have associate attributes with this method you can added attribute to TRObject g...
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
Long64_t GetNEvtSigTrain()
return number of signal training events in dataset
const Event * GetEvent() const
returns event without transformations
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
Long64_t GetNEvtBkgdTrain()
return number of background training events in dataset
std::vector< Float_t > & GetValues()
const char * GetName() const override
Bool_t IsModelPersistence() 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.
void NoErrorCalc(Double_t *const err, Double_t *const errUpper)
void TestClassification() override
initialization
ROOT::R::TRFunctionImport asfactor
static Bool_t IsModuleLoaded
std::vector< Double_t > GetMvaValues(Long64_t firstEvt=0, Long64_t lastEvt=-1, Bool_t logProgress=false) override
get all the MVA values for the events of the current Data type
ROOT::R::TRObject * fModel
MethodRSVM(const TString &jobName, const TString &methodTitle, DataSetInfo &theData, const TString &theOption="")
ROOT::R::TRFunctionImport svm
void GetHelpMessage() const override
Double_t GetMvaValue(Double_t *errLower=nullptr, Double_t *errUpper=nullptr) override
ROOT::R::TRFunctionImport predict
Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets) override
void DeclareOptions() override
void ProcessOptions() override
std::vector< std::string > fFactorTrain
ROOT::R::TRDataFrame fDfTrain
RMethodBase(const TString &jobName, Types::EMVA methodType, const TString &methodTitle, DataSetInfo &dsi, const TString &theOption="", ROOT::R::TRInterface &_r=ROOT::R::TRInterface::Instance())
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.
const Rcpp::internal::NamedPlaceHolder & Label
create variable transformations
MsgLogger & Endl(MsgLogger &ml)