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
24Tracking data from training. Eg, From deep learning record loss for each Epoch
25
26*/
27
28
30
31////////////////////////////////////////////////////////////////////////////////
32/// constructor
33
35{
36}
37
39{
40 for (auto p : fHistoryData) {
41 delete p;
42 }
43}
44
46{
47 if (!fHistoryMap.count(Property))
48 {
49 fHistoryMap[Property]=fHistoryData.size();
51 fHistoryData.push_back(data);
52 }
53 int iHistory=fHistoryMap.at(Property);
54 //std::cout<<"HISTORY!"<<"Adding value ("<<Property<<"):"<<stage<<"\t"<<value<<std::endl;
55 fHistoryData.at(iHistory)->push_back({stage,value});
56}
57
59{
60 //if (fHistoryData.empty()) return;
61 for ( const auto &element : fHistoryMap ) {
62 TString property = element.first;
63 Int_t iHistory = element.second;
64 Int_t nBins=fHistoryData.at(iHistory)->size();
65 Double_t xMin=fHistoryData.at(iHistory)->front().first;
66 Double_t xMax=fHistoryData.at(iHistory)->back().first;
67 Double_t BinSize=(xMax-xMin)/(Double_t)(nBins-1);
68 TH1D* h=new TH1D("TrainingHistory_"+Name+"_"+property,"TrainingHistory_"+Name+"_"+property,nBins,xMin-0.5*BinSize,xMax+0.5*BinSize);
69 for (int i=0; i<nBins; i++) {
70 h->AddBinContent(i+1,fHistoryData.at(iHistory)->at(i).second);
71 }
72 h->Print();
73 if (h!=0) {
74 h->Write();
75 delete h;
76 }
77
78 }
79}
#define h(i)
Definition: RSha256.hxx:106
int Int_t
Definition: RtypesCore.h:41
double Double_t
Definition: RtypesCore.h:55
1-D histogram with a double per channel (see TH1 documentation)}
Definition: TH1.h:614
void AddValue(TString Property, Int_t stage, Double_t value)
std::vector< std::pair< Int_t, Double_t > > IterationRecord
void SaveHistory(TString Name)
TrainingHistory()
constructor
Basic string class.
Definition: TString.h:131
const char * Name
Definition: TXMLSetup.cxx:66