ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MethodLD.h
Go to the documentation of this file.
1 // Author: Krzysztof Danielowski, Kamil Kraszewski, Maciej Kruk, Jan Therhaag
2 
3 /**********************************************************************************
4  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
5  * Package: TMVA *
6  * Class : MethodLD *
7  * Web : http://tmva.sourceforge.net *
8  * *
9  * Description: *
10  * Linear Discriminant (Simple Linear Regression) *
11  * *
12  * Authors (alphabetical): *
13  * Krzysztof Danielowski <danielow@cern.ch> - IFJ PAN & AGH, Poland *
14  * Kamil Kraszewski <kalq@cern.ch> - IFJ PAN & UJ, Poland *
15  * Maciej Kruk <mkruk@cern.ch> - IFJ PAN & AGH, Poland *
16  * Peter Speckmayer <peter.speckmayer@cern.ch> - CERN, Switzerland *
17  * Jan Therhaag <therhaag@physik.uni-bonn.de> - Uni Bonn, Germany *
18  * *
19  * Copyright (c) 2008-2011: *
20  * CERN, Switzerland *
21  * PAN, Poland *
22  * U. of Bonn, Germany *
23  * *
24  * Redistribution and use in source and binary forms, with or without *
25  * modification, are permitted according to the terms listed in LICENSE *
26  * (http://tmva.sourceforge.net/LICENSE) *
27  * *
28  **********************************************************************************/
29 
30 #ifndef ROOT_TMVA_MethodLD
31 #define ROOT_TMVA_MethodLD
32 
33 //////////////////////////////////////////////////////////////////////////
34 // //
35 // MethodLD //
36 // //
37 // Linear Discriminant //
38 // Can compute multidimensional output for regression //
39 // (although it computes every dimension separately) //
40 // //
41 //////////////////////////////////////////////////////////////////////////
42 
43 #include <vector>
44 
45 #ifndef ROOT_TMVA_MethodBase
46 #include "TMVA/MethodBase.h"
47 #endif
48 #ifndef ROOT_TMatrixDfwd
49 #include "TMatrixDfwd.h"
50 #endif
51 
52 namespace TMVA {
53 
54  class MethodLD : public MethodBase {
55 
56  public:
57 
58  // constructor
59  MethodLD( const TString& jobName,
60  const TString& methodTitle,
61  DataSetInfo& dsi,
62  const TString& theOption = "LD",
63  TDirectory* theTargetDir = 0 );
64 
65  // constructor
66  MethodLD( DataSetInfo& dsi,
67  const TString& theWeightFile,
68  TDirectory* theTargetDir = 0 );
69 
70  // destructor
71  virtual ~MethodLD( void );
72 
73  Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
74 
75  // training method
76  void Train( void );
77 
78  // calculate the MVA value
79  Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 );
80 
81  // calculate the Regression value
82  virtual const std::vector<Float_t>& GetRegressionValues();
83 
85 
86  void AddWeightsXMLTo ( void* parent ) const;
87 
88  void ReadWeightsFromStream( std::istream & i );
89  void ReadWeightsFromXML ( void* wghtnode );
90 
91  const Ranking* CreateRanking();
92  void DeclareOptions();
93  void ProcessOptions();
94 
95  protected:
96 
97  void MakeClassSpecific( std::ostream&, const TString& ) const;
98  void GetHelpMessage() const;
99 
100  private:
101 
102  Int_t fNRegOut; // size of the output
103 
104  TMatrixD *fSumMatx; // Sum of coordinates product matrix
105  TMatrixD *fSumValMatx; // Sum of values multiplied by coordinates
106  TMatrixD *fCoeffMatx; // Matrix of coefficients
107  std::vector< std::vector<Double_t>* > *fLDCoeff; // LD coefficients
108 
109  // default initialisation called by all constructors
110  void Init( void );
111 
112  // Initialization and allocation of matrices
113  void InitMatrices( void );
114 
115  // Compute fSumMatx
116  void GetSum( void );
117 
118  // Compute fSumValMatx
119  void GetSumVal( void );
120 
121  // get LD coefficients
122  void GetLDCoeff( void );
123 
124  // nice output
125  void PrintCoefficients( void );
126 
127  ClassDef(MethodLD,0) //Linear discriminant analysis
128  };
129 } // namespace TMVA
130 
131 #endif // MethodLD_H
virtual const std::vector< Float_t > & GetRegressionValues()
Calculates the regression output.
Definition: MethodLD.cxx:178
const Ranking * CreateRanking()
computes ranking of input variables
Definition: MethodLD.cxx:446
std::vector< std::vector< Double_t > * > * fLDCoeff
Definition: MethodLD.h:107
Bool_t HasAnalysisType(Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets)
LD can handle classification with 2 classes and regression with one regression-target.
Definition: MethodLD.cxx:122
void GetSumVal(void)
Calculates the vector transposed(X)*W*Y with Y being the target vector.
Definition: MethodLD.cxx:258
EAnalysisType
Definition: Types.h:124
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual ~MethodLD(void)
destructor
Definition: MethodLD.cxx:106
TMatrixD * fSumValMatx
Definition: MethodLD.h:105
void PrintCoefficients(void)
Display the classification/regression coefficients for each variable.
Definition: MethodLD.cxx:477
TMatrixD * fCoeffMatx
Definition: MethodLD.h:106
void ReadWeightsFromXML(void *wghtnode)
read coefficients from xml weight file
Definition: MethodLD.cxx:367
Double_t GetMvaValue(Double_t *err=0, Double_t *errUpper=0)
Returns the MVA classification output.
Definition: MethodLD.cxx:153
#define ClassDef(name, id)
Definition: Rtypes.h:254
MethodLD(const TString &jobName, const TString &methodTitle, DataSetInfo &dsi, const TString &theOption="LD", TDirectory *theTargetDir=0)
void MakeClassSpecific(std::ostream &, const TString &) const
write LD-specific classifier response
Definition: MethodLD.cxx:404
Int_t fNRegOut
Definition: MethodLD.h:102
void ReadWeightsFromStream(std::istream &i)
read LD coefficients from weight file
Definition: MethodLD.cxx:336
void AddWeightsXMLTo(void *parent) const
create XML description for LD classification and regression (for arbitrary number of output classes/t...
Definition: MethodLD.cxx:349
unsigned int UInt_t
Definition: RtypesCore.h:42
void DeclareOptions()
MethodLD options.
Definition: MethodLD.cxx:461
double Double_t
Definition: RtypesCore.h:55
Describe directory structure in memory.
Definition: TDirectory.h:44
int type
Definition: TGX11.cxx:120
void GetSum(void)
Calculates the matrix transposed(X)*W*X with W being the diagonal weight matrix and X the coordinates...
Definition: MethodLD.cxx:221
void GetLDCoeff(void)
Calculates the coeffiecients used for classification/regression.
Definition: MethodLD.cxx:298
void Train(void)
compute fSumMatx
Definition: MethodLD.cxx:136
void InitMatrices(void)
Initializaton method; creates global matrices and vectors.
Definition: MethodLD.cxx:209
void Init(void)
default initialization called by all constructors
Definition: MethodLD.cxx:89
virtual void ReadWeightsFromStream(std::istream &)=0
void GetHelpMessage() const
get help message text
Definition: MethodLD.cxx:528
TMatrixD * fSumMatx
Definition: MethodLD.h:104
void ProcessOptions()
this is the preparation for training
Definition: MethodLD.cxx:469