Logo ROOT   6.08/07
Reference Guide
MethodRSVM.h
Go to the documentation of this file.
1 // @(#)root/tmva/rmva $Id$
2 // Author: Omar Zapata,Lorenzo Moneta, Sergei Gleyzer 2015
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : RMethodRSVM *
8  * *
9  * Description: *
10  * R´s Package RSVM method based on ROOTR *
11  * *
12  **********************************************************************************/
13 
14 #ifndef ROOT_TMVA_RMethodRSVM
15 #define ROOT_TMVA_RMethodRSVM
16 
17 //////////////////////////////////////////////////////////////////////////
18 // //
19 // RMethodRSVM //
20 // //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #ifndef ROOT_TMVA_RMethodBase
25 #include "TMVA/RMethodBase.h"
26 #endif
27 
28 namespace TMVA {
29 
30  class Factory; // DSMTEST
31  class Reader; // DSMTEST
32  class DataSetManager; // DSMTEST
33  class Types;
34  class MethodRSVM : public RMethodBase {
35 
36  public :
37 
38  // constructors
39  MethodRSVM(const TString &jobName,
40  const TString &methodTitle,
41  DataSetInfo &theData,
42  const TString &theOption = "");
43 
45  const TString &theWeightFile);
46 
47 
48  ~MethodRSVM(void);
49  void Train();
50  // options treatment
51  void Init();
52  void DeclareOptions();
53  void ProcessOptions();
54  // create ranking
56  {
57  return NULL; // = 0;
58  }
59 
60 
61  Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets);
62 
63  // performs classifier testing
64  virtual void TestClassification();
65 
66 
67  Double_t GetMvaValue(Double_t *errLower = 0, Double_t *errUpper = 0);
68 
70  // the actual "weights"
71  virtual void AddWeightsXMLTo(void *parent) const {} // = 0;
72  virtual void ReadWeightsFromXML(void *wghtnode) {} // = 0;
73  virtual void ReadWeightsFromStream(std::istream &) {} //= 0; // backward compatibility
74  void ReadModelFromFile();
75 
76  // signal/background classification response for all current set of data
77  virtual std::vector<Double_t> GetMvaValues(Long64_t firstEvt = 0, Long64_t lastEvt = -1, Bool_t logProgress = false);
78 
79  private :
81  friend class Factory; // DSMTEST
82  friend class Reader; // DSMTEST
83  protected:
85  std::vector<Float_t> fProbResultForTrainSig;
86  std::vector<Float_t> fProbResultForTestSig;
87 
88  //Booking options
89  Bool_t fScale;//A logical vector indicating the variables to be scaled. If
90  //‘scale’ is of length 1, the value is recycled as many times
91  //as needed. Per default, data are scaled internally (both ‘x’
92  //and ‘y’ variables) to zero mean and unit variance. The center
93  //and scale values are returned and used for later predictions.
94  TString fType;//‘svm’ can be used as a classification machine, as a
95  //regression machine, or for novelty detection. Depending of
96  //whether ‘y’ is a factor or not, the default setting for
97  //‘type’ is ‘C-classification’ or ‘eps-regression’,
98  //respectively, but may be overwritten by setting an explicit value.
99  //Valid options are:
100  // - ‘C-classification’
101  // - ‘nu-classification’
102  // - ‘one-classification’ (for novelty detection)
103  // - ‘eps-regression’
104  // - ‘nu-regression’
105  TString fKernel;//the kernel used in training and predicting. You might
106  //consider changing some of the following parameters, depending on the kernel type.
107  //linear: u'*v
108  //polynomial: (gamma*u'*v + coef0)^degree
109  //radial basis: exp(-gamma*|u-v|^2)
110  //sigmoid: tanh(gamma*u'*v + coef0)
111  Int_t fDegree;//parameter needed for kernel of type ‘polynomial’ (default: 3)
112  Float_t fGamma;//parameter needed for all kernels except ‘linear’ (default: 1/(data dimension))
113  Float_t fCoef0;//parameter needed for kernels of type ‘polynomial’ and ‘sigmoid’ (default: 0)
114  Float_t fCost;//cost of constraints violation (default: 1)-it is the
115  //‘C’-constant of the regularization term in the Lagrange formulation.
116  Float_t fNu;//parameter needed for ‘nu-classification’, ‘nu-regression’, and ‘one-classification’
117  Float_t fCacheSize;//cache memory in MB (default 40)
118  Float_t fTolerance;//tolerance of termination criterion (default: 0.001)
119  Float_t fEpsilon;//epsilon in the insensitive-loss function (default: 0.1)
120  Bool_t fShrinking;//option whether to use the shrinking-heuristics (default: ‘TRUE’)
121  Float_t fCross;//if a integer value k>0 is specified, a k-fold cross
122  //validation on the training data is performed to assess the
123  //quality of the model: the accuracy rate for classification
124  //and the Mean Squared Error for regression
125  Bool_t fProbability;//logical indicating whether the model should allow for probability predictions.
126  Bool_t fFitted;//logical indicating whether the fitted values should be computed and included in the model or not (default: ‘TRUE’)
127 
129  ROOT::R::TRFunctionImport svm;
130  ROOT::R::TRFunctionImport predict;
131  ROOT::R::TRFunctionImport asfactor;
132  ROOT::R::TRObject *fModel;
133  // get help message text
134  void GetHelpMessage() const;
135 
136  ClassDef(MethodRSVM, 0)
137  };
138 } // namespace TMVA
139 #endif
Float_t fEpsilon
Definition: MethodRSVM.h:119
std::vector< Float_t > fProbResultForTrainSig
Definition: MethodRSVM.h:85
long long Long64_t
Definition: RtypesCore.h:69
Bool_t fProbability
Definition: MethodRSVM.h:125
float Float_t
Definition: RtypesCore.h:53
EAnalysisType
Definition: Types.h:129
virtual void ReadWeightsFromXML(void *wghtnode)
Definition: MethodRSVM.h:72
ROOT::R::TRObject * fModel
Definition: MethodRSVM.h:132
Basic string class.
Definition: TString.h:137
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
Definition: MethodRSVM.cxx:273
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
ROOT::R::TRFunctionImport asfactor
Definition: MethodRSVM.h:131
ROOT::R::TRFunctionImport svm
Definition: MethodRSVM.h:129
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual void ReadWeightsFromStream(std::istream &)
Definition: MethodRSVM.h:73
static Bool_t IsModuleLoaded
Definition: MethodRSVM.h:128
void GetHelpMessage() const
Definition: MethodRSVM.cxx:371
ROOT::R::TRFunctionImport predict
Definition: MethodRSVM.h:130
virtual void AddWeightsXMLTo(void *parent) const
Definition: MethodRSVM.h:71
std::vector< Float_t > fProbResultForTestSig
Definition: MethodRSVM.h:86
unsigned int UInt_t
Definition: RtypesCore.h:42
Double_t GetMvaValue(Double_t *errLower=0, Double_t *errUpper=0)
Definition: MethodRSVM.cxx:252
UInt_t fMvaCounter
Definition: MethodRSVM.h:84
double Double_t
Definition: RtypesCore.h:55
int type
Definition: TGX11.cxx:120
Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
Definition: MethodRSVM.cxx:118
MethodRSVM(const TString &jobName, const TString &methodTitle, DataSetInfo &theData, const TString &theOption="")
Definition: MethodRSVM.cxx:50
Float_t fCacheSize
Definition: MethodRSVM.h:117
Abstract ClassifierFactory template that handles arbitrary types.
virtual void TestClassification()
initialization
Definition: MethodRSVM.cxx:243
void ReadModelFromFile()
Definition: MethodRSVM.cxx:356
#define NULL
Definition: Rtypes.h:82
const Ranking * CreateRanking()
Definition: MethodRSVM.h:55
virtual void ReadWeightsFromStream(std::istream &)=0
DataSetManager * fDataSetManager
Definition: MethodRSVM.h:80
Float_t fTolerance
Definition: MethodRSVM.h:118