Logo ROOT   6.08/07
Reference Guide
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 
64  // constructor
65  MethodLD( DataSetInfo& dsi,
66  const TString& theWeightFile);
67 
68  // destructor
69  virtual ~MethodLD( void );
70 
71  Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
72 
73  // training method
74  void Train( void );
75 
76  // calculate the MVA value
77  Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 );
78 
79  // calculate the Regression value
80  virtual const std::vector<Float_t>& GetRegressionValues();
81 
83 
84  void AddWeightsXMLTo ( void* parent ) const;
85 
86  void ReadWeightsFromStream( std::istream & i );
87  void ReadWeightsFromXML ( void* wghtnode );
88 
89  const Ranking* CreateRanking();
90  void DeclareOptions();
91  void ProcessOptions();
92 
93  protected:
94 
95  void MakeClassSpecific( std::ostream&, const TString& ) const;
96  void GetHelpMessage() const;
97 
98  private:
99 
100  Int_t fNRegOut; // size of the output
101 
102  TMatrixD *fSumMatx; // Sum of coordinates product matrix
103  TMatrixD *fSumValMatx; // Sum of values multiplied by coordinates
104  TMatrixD *fCoeffMatx; // Matrix of coefficients
105  std::vector< std::vector<Double_t>* > *fLDCoeff; // LD coefficients
106 
107  // default initialisation called by all constructors
108  void Init( void );
109 
110  // Initialization and allocation of matrices
111  void InitMatrices( void );
112 
113  // Compute fSumMatx
114  void GetSum( void );
115 
116  // Compute fSumValMatx
117  void GetSumVal( void );
118 
119  // get LD coefficients
120  void GetLDCoeff( void );
121 
122  // nice output
123  void PrintCoefficients( void );
124 
125  ClassDef(MethodLD,0); //Linear discriminant analysis
126  };
127 } // namespace TMVA
128 
129 #endif // MethodLD_H
virtual const std::vector< Float_t > & GetRegressionValues()
Calculates the regression output.
Definition: MethodLD.cxx:183
const Ranking * CreateRanking()
computes ranking of input variables
Definition: MethodLD.cxx:451
std::vector< std::vector< Double_t > *> * fLDCoeff
Definition: MethodLD.h:105
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:125
void GetSumVal(void)
Calculates the vector transposed(X)*W*Y with Y being the target vector.
Definition: MethodLD.cxx:263
EAnalysisType
Definition: Types.h:129
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:109
TMatrixD * fSumValMatx
Definition: MethodLD.h:103
void PrintCoefficients(void)
Display the classification/regression coefficients for each variable.
Definition: MethodLD.cxx:482
TMatrixD * fCoeffMatx
Definition: MethodLD.h:104
void ReadWeightsFromXML(void *wghtnode)
read coefficients from xml weight file
Definition: MethodLD.cxx:372
Double_t GetMvaValue(Double_t *err=0, Double_t *errUpper=0)
Returns the MVA classification output.
Definition: MethodLD.cxx:158
#define ClassDef(name, id)
Definition: Rtypes.h:254
Int_t fNRegOut
Definition: MethodLD.h:100
void ReadWeightsFromStream(std::istream &i)
read LD coefficients from weight file
Definition: MethodLD.cxx:341
unsigned int UInt_t
Definition: RtypesCore.h:42
void DeclareOptions()
MethodLD options.
Definition: MethodLD.cxx:466
double Double_t
Definition: RtypesCore.h:55
void MakeClassSpecific(std::ostream &, const TString &) const
write LD-specific classifier response
Definition: MethodLD.cxx:409
MethodLD(const TString &jobName, const TString &methodTitle, DataSetInfo &dsi, const TString &theOption="LD")
standard constructor for the LD
Definition: MethodLD.cxx:63
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:226
Abstract ClassifierFactory template that handles arbitrary types.
void GetLDCoeff(void)
Calculates the coeffiecients used for classification/regression.
Definition: MethodLD.cxx:303
void Train(void)
compute fSumMatx
Definition: MethodLD.cxx:139
void InitMatrices(void)
Initializaton method; creates global matrices and vectors.
Definition: MethodLD.cxx:214
void GetHelpMessage() const
get help message text
Definition: MethodLD.cxx:533
void Init(void)
default initialization called by all constructors
Definition: MethodLD.cxx:92
virtual void ReadWeightsFromStream(std::istream &)=0
TMatrixD * fSumMatx
Definition: MethodLD.h:102
void AddWeightsXMLTo(void *parent) const
create XML description for LD classification and regression (for arbitrary number of output classes/t...
Definition: MethodLD.cxx:354
void ProcessOptions()
this is the preparation for training
Definition: MethodLD.cxx:474