Logo ROOT  
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 #include "TMVA/MethodBase.h"
46 #include "TMatrixDfwd.h"
47 
48 namespace TMVA {
49 
50  class MethodLD : public MethodBase {
51 
52  public:
53 
54  // constructor
55  MethodLD( const TString& jobName,
56  const TString& methodTitle,
57  DataSetInfo& dsi,
58  const TString& theOption = "LD");
59 
60  // constructor
61  MethodLD( DataSetInfo& dsi,
62  const TString& theWeightFile);
63 
64  // destructor
65  virtual ~MethodLD( void );
66 
67  Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
68 
69  // training method
70  void Train( void );
71 
72  // calculate the MVA value
73  Double_t GetMvaValue( Double_t* err = 0, Double_t* errUpper = 0 );
74 
75  // calculate the Regression value
76  virtual const std::vector<Float_t>& GetRegressionValues();
77 
79 
80  void AddWeightsXMLTo ( void* parent ) const;
81 
82  void ReadWeightsFromStream( std::istream & i );
83  void ReadWeightsFromXML ( void* wghtnode );
84 
85  const Ranking* CreateRanking();
86  void DeclareOptions();
87  void ProcessOptions();
88 
89  protected:
90 
91  void MakeClassSpecific( std::ostream&, const TString& ) const;
92  void GetHelpMessage() const;
93 
94  private:
95 
96  Int_t fNRegOut; // size of the output
97 
98  TMatrixD *fSumMatx; // Sum of coordinates product matrix
99  TMatrixD *fSumValMatx; // Sum of values multiplied by coordinates
100  TMatrixD *fCoeffMatx; // Matrix of coefficients
101  std::vector< std::vector<Double_t>* > *fLDCoeff; // LD coefficients
102 
103  // default initialisation called by all constructors
104  void Init( void );
105 
106  // Initialization and allocation of matrices
107  void InitMatrices( void );
108 
109  // Compute fSumMatx
110  void GetSum( void );
111 
112  // Compute fSumValMatx
113  void GetSumVal( void );
114 
115  // get LD coefficients
116  void GetLDCoeff( void );
117 
118  // nice output
119  void PrintCoefficients( void );
120 
121  ClassDef(MethodLD,0); //Linear discriminant analysis
122  };
123 } // namespace TMVA
124 
125 #endif // MethodLD_H
TMatrixDfwd.h
TMVA::MethodLD::HasAnalysisType
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:133
TMVA::MethodLD::ProcessOptions
void ProcessOptions()
this is the preparation for training
Definition: MethodLD.cxx:482
TMVA::MethodLD::GetSum
void GetSum(void)
Calculates the matrix transposed(X)*W*X with W being the diagonal weight matrix and X the coordinates...
Definition: MethodLD.cxx:234
TMVA::MethodLD::MethodLD
MethodLD(const TString &jobName, const TString &methodTitle, DataSetInfo &dsi, const TString &theOption="LD")
standard constructor for the LD
Definition: MethodLD.cxx:71
TMVA::MethodBase::ReadWeightsFromStream
virtual void ReadWeightsFromStream(std::istream &)=0
TMVA::Ranking
Ranking for variables in method (implementation)
Definition: Ranking.h:48
TMVA::MethodLD::Init
void Init(void)
default initialization called by all constructors
Definition: MethodLD.cxx:100
TMVA::MethodLD::fLDCoeff
std::vector< std::vector< Double_t > * > * fLDCoeff
Definition: MethodLD.h:101
TMVA::MethodLD::fCoeffMatx
TMatrixD * fCoeffMatx
Definition: MethodLD.h:100
MethodBase.h
TMVA::MethodLD::GetMvaValue
Double_t GetMvaValue(Double_t *err=0, Double_t *errUpper=0)
Returns the MVA classification output.
Definition: MethodLD.cxx:166
TString
Basic string class.
Definition: TString.h:136
TMatrixT< Double_t >
TMVA::MethodLD::fNRegOut
Int_t fNRegOut
Definition: MethodLD.h:96
TMVA::MethodLD::fSumValMatx
TMatrixD * fSumValMatx
Definition: MethodLD.h:99
bool
TMVA::MethodLD::GetSumVal
void GetSumVal(void)
Calculates the vector transposed(X)*W*Y with Y being the target vector.
Definition: MethodLD.cxx:271
TMVA::MethodLD::ReadWeightsFromStream
virtual void ReadWeightsFromStream(std::istream &)=0
TMVA::MethodLD::ReadWeightsFromXML
void ReadWeightsFromXML(void *wghtnode)
read coefficients from xml weight file
Definition: MethodLD.cxx:380
TMVA::DataSetInfo
Class that contains all the data information.
Definition: DataSetInfo.h:62
TMVA::Types::EAnalysisType
EAnalysisType
Definition: Types.h:128
TMVA::MethodLD::PrintCoefficients
void PrintCoefficients(void)
Display the classification/regression coefficients for each variable.
Definition: MethodLD.cxx:490
TMVA::MethodLD::AddWeightsXMLTo
void AddWeightsXMLTo(void *parent) const
create XML description for LD classification and regression (for arbitrary number of output classes/t...
Definition: MethodLD.cxx:362
TMVA::MethodBase
Virtual base Class for all MVA method.
Definition: MethodBase.h:111
TMVA::MethodLD::InitMatrices
void InitMatrices(void)
Initialization method; creates global matrices and vectors.
Definition: MethodLD.cxx:222
TMVA::MethodLD::DeclareOptions
void DeclareOptions()
MethodLD options.
Definition: MethodLD.cxx:474
unsigned int
TMVA::MethodLD::GetLDCoeff
void GetLDCoeff(void)
Calculates the coefficients used for classification/regression.
Definition: MethodLD.cxx:311
TMVA::MethodLD::MakeClassSpecific
void MakeClassSpecific(std::ostream &, const TString &) const
write LD-specific classifier response
Definition: MethodLD.cxx:417
Double_t
double Double_t
Definition: RtypesCore.h:59
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TMVA::MethodLD::fSumMatx
TMatrixD * fSumMatx
Definition: MethodLD.h:98
TMVA::MethodLD::Train
void Train(void)
compute fSumMatx
Definition: MethodLD.cxx:147
TMVA::MethodLD::GetHelpMessage
void GetHelpMessage() const
get help message text
Definition: MethodLD.cxx:541
TMVA::MethodLD::GetRegressionValues
virtual const std::vector< Float_t > & GetRegressionValues()
Calculates the regression output.
Definition: MethodLD.cxx:191
type
int type
Definition: TGX11.cxx:121
TMVA::MethodLD::~MethodLD
virtual ~MethodLD(void)
destructor
Definition: MethodLD.cxx:117
TMVA::MethodLD::CreateRanking
const Ranking * CreateRanking()
computes ranking of input variables
Definition: MethodLD.cxx:459
TMVA::MethodLD
Linear Discriminant.
Definition: MethodLD.h:50
TMVA
create variable transformations
Definition: GeneticMinimizer.h:22
int