Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:01

0001 // Author: Krzysztof Danielowski, Kamil Kraszewski, Maciej Kruk, Jan Therhaag
0002 
0003 /**********************************************************************************
0004  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
0005  * Package: TMVA                                                                  *
0006  * Class  : MethodLD                                                              *
0007  *                                             *
0008  *                                                                                *
0009  * Description:                                                                   *
0010  *      Linear Discriminant (Simple Linear Regression)                            *
0011  *                                                                                *
0012  * Authors (alphabetical):                                                        *
0013  *      Krzysztof Danielowski <danielow@cern.ch> - IFJ PAN & AGH, Poland          *
0014  *      Kamil Kraszewski      <kalq@cern.ch>     - IFJ PAN & UJ, Poland           *
0015  *      Maciej Kruk           <mkruk@cern.ch>    - IFJ PAN & AGH, Poland          *
0016  *      Peter Speckmayer      <peter.speckmayer@cern.ch>  - CERN, Switzerland     *
0017  *      Jan Therhaag          <therhaag@physik.uni-bonn.de> - Uni Bonn, Germany   *
0018  *                                                                                *
0019  * Copyright (c) 2008-2011:                                                       *
0020  *      CERN, Switzerland                                                         *
0021  *      PAN, Poland                                                               *
0022  *      U. of Bonn, Germany                                                       *
0023  *                                                                                *
0024  * Redistribution and use in source and binary forms, with or without             *
0025  * modification, are permitted according to the terms listed in LICENSE           *
0026  * (see tmva/doc/LICENSE)                                          *
0027  *                                                                                *
0028  **********************************************************************************/
0029 
0030 #ifndef ROOT_TMVA_MethodLD
0031 #define ROOT_TMVA_MethodLD
0032 
0033 //////////////////////////////////////////////////////////////////////////
0034 //                                                                      //
0035 // MethodLD                                                             //
0036 //                                                                      //
0037 // Linear Discriminant                                                  //
0038 // Can compute multidimensional output for regression                   //
0039 // (although it computes every dimension separately)                    //
0040 //                                                                      //
0041 //////////////////////////////////////////////////////////////////////////
0042 
0043 #include <vector>
0044 
0045 #include "TMVA/MethodBase.h"
0046 #include "TMatrixDfwd.h"
0047 
0048 namespace TMVA {
0049 
0050    class MethodLD : public MethodBase {
0051 
0052    public:
0053 
0054       // constructor
0055       MethodLD( const TString& jobName,
0056                 const TString& methodTitle,
0057                 DataSetInfo& dsi,
0058                 const TString& theOption = "LD");
0059 
0060       // constructor
0061       MethodLD( DataSetInfo& dsi,
0062                 const TString& theWeightFile);
0063 
0064       // destructor
0065       virtual ~MethodLD( void );
0066 
0067       Bool_t HasAnalysisType( Types::EAnalysisType type, UInt_t numberClasses, UInt_t numberTargets );
0068 
0069       // training method
0070       void Train( void );
0071 
0072       // calculate the MVA value
0073       Double_t GetMvaValue( Double_t* err = nullptr, Double_t* errUpper = nullptr );
0074 
0075       // calculate the Regression value
0076       virtual const std::vector<Float_t>& GetRegressionValues();
0077 
0078       using MethodBase::ReadWeightsFromStream;
0079 
0080       void AddWeightsXMLTo      ( void* parent ) const;
0081 
0082       void ReadWeightsFromStream( std::istream & i );
0083       void ReadWeightsFromXML   ( void* wghtnode );
0084 
0085       const Ranking* CreateRanking();
0086       void DeclareOptions();
0087       void ProcessOptions();
0088 
0089    protected:
0090 
0091       void MakeClassSpecific( std::ostream&, const TString& ) const;
0092       void GetHelpMessage() const;
0093 
0094    private:
0095 
0096       Int_t fNRegOut; ///< size of the output
0097 
0098       TMatrixD *fSumMatx;              ///< Sum of coordinates product matrix
0099       TMatrixD *fSumValMatx;           ///< Sum of values multiplied by coordinates
0100       TMatrixD *fCoeffMatx;            ///< Matrix of coefficients
0101       std::vector< std::vector<Double_t>* > *fLDCoeff; ///< LD coefficients
0102 
0103       // default initialisation called by all constructors
0104       void Init( void );
0105 
0106       // Initialization and allocation of matrices
0107       void InitMatrices( void );
0108 
0109       // Compute fSumMatx
0110       void GetSum( void );
0111 
0112       // Compute fSumValMatx
0113       void GetSumVal( void );
0114 
0115       // get LD coefficients
0116       void GetLDCoeff( void );
0117 
0118       // nice output
0119       void PrintCoefficients( void );
0120 
0121       ClassDef(MethodLD,0); //Linear discriminant analysis
0122    };
0123 } // namespace TMVA
0124 
0125 #endif // MethodLD_H