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
48namespace 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
int Int_t
Definition: RtypesCore.h:45
unsigned int UInt_t
Definition: RtypesCore.h:46
bool Bool_t
Definition: RtypesCore.h:63
double Double_t
Definition: RtypesCore.h:59
#define ClassDef(name, id)
Definition: Rtypes.h:325
int type
Definition: TGX11.cxx:121
Class that contains all the data information.
Definition: DataSetInfo.h:62
Virtual base Class for all MVA method.
Definition: MethodBase.h:111
virtual void ReadWeightsFromStream(std::istream &)=0
Linear Discriminant.
Definition: MethodLD.h:50
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
void GetHelpMessage() const
get help message text
Definition: MethodLD.cxx:541
const Ranking * CreateRanking()
computes ranking of input variables
Definition: MethodLD.cxx:459
Int_t fNRegOut
Definition: MethodLD.h:96
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
TMatrixD * fCoeffMatx
Definition: MethodLD.h:100
MethodLD(const TString &jobName, const TString &methodTitle, DataSetInfo &dsi, const TString &theOption="LD")
standard constructor for the LD
Definition: MethodLD.cxx:71
std::vector< std::vector< Double_t > * > * fLDCoeff
Definition: MethodLD.h:101
void DeclareOptions()
MethodLD options.
Definition: MethodLD.cxx:474
void GetLDCoeff(void)
Calculates the coefficients used for classification/regression.
Definition: MethodLD.cxx:311
virtual const std::vector< Float_t > & GetRegressionValues()
Calculates the regression output.
Definition: MethodLD.cxx:191
void ReadWeightsFromStream(std::istream &i)
read LD coefficients from weight file
Definition: MethodLD.cxx:349
void ReadWeightsFromXML(void *wghtnode)
read coefficients from xml weight file
Definition: MethodLD.cxx:380
TMatrixD * fSumValMatx
Definition: MethodLD.h:99
void Init(void)
default initialization called by all constructors
Definition: MethodLD.cxx:100
TMatrixD * fSumMatx
Definition: MethodLD.h:98
void ProcessOptions()
this is the preparation for training
Definition: MethodLD.cxx:482
void PrintCoefficients(void)
Display the classification/regression coefficients for each variable.
Definition: MethodLD.cxx:490
void Train(void)
compute fSumMatx
Definition: MethodLD.cxx:147
virtual ~MethodLD(void)
destructor
Definition: MethodLD.cxx:117
void AddWeightsXMLTo(void *parent) const
create XML description for LD classification and regression (for arbitrary number of output classes/t...
Definition: MethodLD.cxx:362
void MakeClassSpecific(std::ostream &, const TString &) const
write LD-specific classifier response
Definition: MethodLD.cxx:417
void InitMatrices(void)
Initialization method; creates global matrices and vectors.
Definition: MethodLD.cxx:222
Double_t GetMvaValue(Double_t *err=0, Double_t *errUpper=0)
Returns the MVA classification output.
Definition: MethodLD.cxx:166
void GetSumVal(void)
Calculates the vector transposed(X)*W*Y with Y being the target vector.
Definition: MethodLD.cxx:271
Ranking for variables in method (implementation)
Definition: Ranking.h:48
EAnalysisType
Definition: Types.h:128
Basic string class.
Definition: TString.h:136
create variable transformations