Logo ROOT  
Reference Guide
TrainingHistory.cxx
Go to the documentation of this file.
1 /**********************************************************************************
2  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
3  * Package: TMVA *
4  * Class : TrainingHistory *
5  * Web : http://tmva.sourceforge.net *
6  * *
7  * Description: *
8  * Implementation (see header for description) *
9  * *
10  * Author: *
11  * Joseph McKenna <Joseph.McKenna@cern.ch> - Aarhus, Denmark *
12  * *
13  * Copyright (c) 2019: *
14  * Aarhus, Denmark *
15  * *
16  * Redistribution and use in source and binary forms, with or without *
17  * modification, are permitted according to the terms listed in LICENSE *
18  * (http://tmva.sourceforge.net/LICENSE) *
19  **********************************************************************************/
20 
21 /*! \class TMVA::TrainingHistory
22 \ingroup TMVA
23 
24 Tracking data from training. Eg, From deep learning record loss for each Epoch
25 
26 */
27 
28 
29 #include "TMVA/TrainingHistory.h"
30 
31 #include "TH1D.h"
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 /// constructor
35 
37 {
38 }
39 
41 {
42  for (auto p : fHistoryData) {
43  delete p;
44  }
45 }
46 
48 {
49  if (!fHistoryMap.count(Property))
50  {
51  fHistoryMap[Property]=fHistoryData.size();
52  IterationRecord* data=new IterationRecord();
53  fHistoryData.push_back(data);
54  }
55  int iHistory=fHistoryMap.at(Property);
56  //std::cout<<"HISTORY!"<<"Adding value ("<<Property<<"):"<<stage<<"\t"<<value<<std::endl;
57  fHistoryData.at(iHistory)->push_back({stage,value});
58 }
59 
61 {
62  //if (fHistoryData.empty()) return;
63  for ( const auto &element : fHistoryMap ) {
64  TString property = element.first;
65  Int_t iHistory = element.second;
66  Int_t nBins=fHistoryData.at(iHistory)->size();
67  Double_t xMin=fHistoryData.at(iHistory)->front().first;
68  Double_t xMax=fHistoryData.at(iHistory)->back().first;
69  Double_t BinSize=(xMax-xMin)/(Double_t)(nBins-1);
70  TH1D* h=new TH1D("TrainingHistory_"+Name+"_"+property,"TrainingHistory_"+Name+"_"+property,nBins,xMin-0.5*BinSize,xMax+0.5*BinSize);
71  for (int i=0; i<nBins; i++) {
72  h->AddBinContent(i+1,fHistoryData.at(iHistory)->at(i).second);
73  }
74  h->Print();
75  if (h!=0) {
76  h->Write();
77  delete h;
78  }
79 
80  }
81 }
TMVA::TrainingHistory::TrainingHistory
TrainingHistory()
constructor
Definition: TrainingHistory.cxx:36
TrainingHistory.h
TMVA::TrainingHistory::IterationRecord
std::vector< std::pair< Int_t, Double_t > > IterationRecord
Definition: TrainingHistory.h:34
TH1D
1-D histogram with a double per channel (see TH1 documentation)}
Definition: TH1.h:618
TString
Basic string class.
Definition: TString.h:136
h
#define h(i)
Definition: RSha256.hxx:106
TMVA::TrainingHistory::AddValue
void AddValue(TString Property, Int_t stage, Double_t value)
Definition: TrainingHistory.cxx:47
TMVA::TrainingHistory::SaveHistory
void SaveHistory(TString Name)
Definition: TrainingHistory.cxx:60
xmlio::Name
const char * Name
Definition: TXMLSetup.cxx:67
Double_t
double Double_t
Definition: RtypesCore.h:59
TMVA::TrainingHistory::~TrainingHistory
virtual ~TrainingHistory()
Definition: TrainingHistory.cxx:40
TH1D.h
int