Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
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 = nullptr, Double_t* errUpper = nullptr );
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
#define ClassDef(name, id)
Definition Rtypes.h:337
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
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
Double_t GetMvaValue(Double_t *err=nullptr, Double_t *errUpper=nullptr)
Returns the MVA classification output.
Definition MethodLD.cxx:166
const Ranking * CreateRanking()
computes ranking of input variables
Definition MethodLD.cxx:459
Int_t fNRegOut
size of the output
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
Matrix of coefficients.
Definition MethodLD.h:100
std::vector< std::vector< Double_t > * > * fLDCoeff
LD coefficients.
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
Sum of values multiplied by coordinates.
Definition MethodLD.h:99
void Init(void)
default initialization called by all constructors
Definition MethodLD.cxx:100
TMatrixD * fSumMatx
Sum of coordinates product matrix.
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
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
Basic string class.
Definition TString.h:139
create variable transformations