Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files 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 #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 
78  using MethodBase::ReadWeightsFromStream;
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