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