Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
ResultsMulticlass.h
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Peter Speckmayer, Joerg Stelzer, Helge Voss, Jan Therhaag
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : ResultsMulticlass *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Base-class for result-vectors *
12  * *
13  * Authors (alphabetical): *
14  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
15  * Peter Speckmayer <Peter.Speckmayer@cern.ch> - CERN, Switzerland *
16  * Joerg Stelzer <Joerg.Stelzer@cern.ch> - CERN, Switzerland *
17  * Jan Therhaag <Jan.Therhaag@cern.ch> - U of Bonn, Germany *
18  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
19  * *
20  * Copyright (c) 2005-2011: *
21  * CERN, Switzerland *
22  * U. of Victoria, Canada *
23  * MPI-K Heidelberg, Germany *
24  * U. of Bonn, Germany *
25  * *
26  * Redistribution and use in source and binary forms, with or without *
27  * modification, are permitted according to the terms listed in LICENSE *
28  * (http://tmva.sourceforge.net/LICENSE) *
29  **********************************************************************************/
30 
31 #ifndef ROOT_TMVA_ResultsMulticlass
32 #define ROOT_TMVA_ResultsMulticlass
33 
34 //////////////////////////////////////////////////////////////////////////
35 // //
36 // ResultsMulticlass //
37 // //
38 // Class which takes the results of a multiclass classification //
39 // //
40 //////////////////////////////////////////////////////////////////////////
41 
42 #include "TH1F.h"
43 #include "TH2F.h"
44 
45 #include "TMVA/Results.h"
46 #include "TMVA/Event.h"
47 #include "IFitterTarget.h"
48 
49 #include <vector>
50 
51 namespace TMVA {
52 
53  class MsgLogger;
54 
55  class ResultsMulticlass : public Results, public IFitterTarget {
56 
57  public:
58 
59  ResultsMulticlass( const DataSetInfo* dsi, TString resultsName );
60  ~ResultsMulticlass();
61 
62  // setters
63  void SetValue( std::vector<Float_t>& value, Int_t ievt );
64  void Resize( Int_t entries ) { fMultiClassValues.resize( entries ); }
65  using TObject::Clear;
66  virtual void Clear(Option_t *) { fMultiClassValues.clear(); }
67 
68  // getters
69  Long64_t GetSize() const { return fMultiClassValues.size(); }
70  virtual const std::vector< Float_t >& operator[] ( Int_t ievt ) const { return fMultiClassValues.at(ievt); }
71  std::vector<std::vector< Float_t> >* GetValueVector() { return &fMultiClassValues; }
72 
73  Types::EAnalysisType GetAnalysisType() { return Types::kMulticlass; }
74  Float_t GetAchievableEff(UInt_t cls){return fAchievableEff.at(cls);}
75  Float_t GetAchievablePur(UInt_t cls){return fAchievablePur.at(cls);}
76  std::vector<Float_t>& GetAchievableEff(){return fAchievableEff;}
77  std::vector<Float_t>& GetAchievablePur(){return fAchievablePur;}
78 
79  TMatrixD GetConfusionMatrix(Double_t effB);
80 
81  // histogramming
82  void CreateMulticlassPerformanceHistos(TString prefix);
83  void CreateMulticlassHistos( TString prefix, Int_t nbins, Int_t nbins_high);
84 
85  Double_t EstimatorFunction( std::vector<Double_t> & );
86  std::vector<Double_t> GetBestMultiClassCuts(UInt_t targetClass);
87 
88  private:
89 
90  mutable std::vector<std::vector< Float_t> > fMultiClassValues; // mva values (Results)
91  mutable MsgLogger* fLogger; //! message logger
92  MsgLogger& Log() const { return *fLogger; }
93  UInt_t fClassToOptimize;
94  std::vector<Float_t> fAchievableEff;
95  std::vector<Float_t> fAchievablePur;
96  std::vector<std::vector<Double_t> > fBestCuts;
97 
98  // Temporary storage used during GetBestMultiClassCuts
99  std::vector<Float_t> fClassSumWeights;
100  std::vector<Float_t> fEventWeights;
101  std::vector<UInt_t> fEventClasses;
102 
103  protected:
104 
105  ClassDef(ResultsMulticlass,2);
106 
107  };
108 
109 }
110 
111 #endif