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