-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathNeuroBayesTeacher.hh
157 lines (125 loc) · 4.5 KB
/
NeuroBayesTeacher.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
* NeuroBayes Teacher
*
*
* Revision history:
* 2004-June-05 Ulrich Kerzel
* initial revision
*/
#ifndef NEUROBAYESTEACHER_HH_
#define NEUROBAYESTEACHER_HH_
#include "nb_param.hh"
#include "nb_cpp_utils.h"
#include <string>
#include <vector>
class NeuroBayesTeacher{
public:
// Get the singleton instance.
static NeuroBayesTeacher* Instance(ec_t** ec=NULL, int debug=-1, log_func_t log_f=NULL,
void* log_enclosed=NULL, delete_enclosed_func_t log_delete_enclosed=NULL);
// NeuroBayes steering functions
void NB_DEF (bool resetInput=true);
void NB_DEF_TASK (const char* thisTask);
void NB_DEF_TASK (std::string & thisTask);
void NB_DEF_DEBUG(int thisDebug);
void NB_DEF_PRE (int thisPre);
void NB_DEF_INITIALPRUNE (int thisIprune);
void NB_DEF_NODE1(int thisNode1);
void NB_DEF_NODE2(int thisNode2);
void NB_DEF_NODE3(int thisNode3);
void NB_DEF_REG (const char* thisReg);
void NB_DEF_LEARNDIAG (int thisValue);
void NB_DEF_LOSS (const char* thisLoss);
void NB_DEF_SHAPE (const char* thisShape);
void NB_DEF_METHOD(const char* thisMethod);
void NB_DEF_MOM (float thisMom);
void NB_DEF_EPOCH (int thisEpoch);
void NB_DEF_ITER (int thisIter);
void NB_DEF_RTRAIN(float thisRtrain);
void NB_DEF_SPEED (float thisSpeed);
void NB_DEF_MAXLEARN (float thisMaxlearn);
void NB_DEF_RELIMPORTANCE(float thisRelimportance);
void NB_DEF_SURRO (float thisSurro);
void NB_DEF_PRUNEMIN (float thisPrunemin);
void NB_DEF_PRUNEMAX (float thisPrunemax);
void NB_DEF_PRUNERESULT (float thisPruneresult);
void NB_DEF_QUANTILE (float thisQuantile);
// parameter thisDbg in NB_RANVIN(thisJseed, thisJwarm, thisDbg) is deprecated
// and will be ignored
void NB_RANVIN (int thisJseed = 4711,
int thisJwarm = 10,
int thisDbg = -2);
void NB_DEF_LOSSWGT (float thisWeight);
void NB_DEF_TDELTA (float thisWeight);
void NB_DEF_WEIGHT_MODE(int mode);
void NB_DEF_SPLOT_MODE(int mode);
// has to be static: can be called without a teacher-instance is created
// needed by useTargetDistribution before callTeacher is done
static void NB_TABDEF1(float* targetDist, float* targetWeight,
int numTarget, float* targetTab, int numTab,
common_t* com1=NULL);
void SetIndividualPreproFlag (int thisIvar, int thisFlag,const char* varname = "");
void SetIndividualPreproParameter(int thisIvar, int thisParNr,
float thisValue);
// define training target, weight:
void SetTarget(float thisTarget);
void SetWeight(float thisWeight,float thisWeight2 = 1);
void SetNextInput(int thisNvar,float* thisVars);
// hint for efficient memory allocation
void SetNEvents(int nevt);
// start network training
void TrainNet(bool write_output_files=true);
// misc. setups
void SetOutputFile(const char* thisName);
void SetHistosFile(const char* thisName);
void SetCArrayFile(const char* thisName);
float* nb_get_expertise();
//create correl_signi.txt file
void nb_infoout(float* weightsum,float* total,int* keep,int* rank,
float* single,float* added,float* global,float* loss,
int* nvar,int* index);
void nb_correl_signi(const char filename_txt[],
const char filename_html[]);
void nb_correl_signi(char** varnames,const char filename_txt[],
const char filename_html[]);
char** nb_get_varnames(int* n_var_all);
int* nb_get_individual_prepro_flags(int* n_var_all);
// just to check if things work
void SayHello();
// Destructor private because it is a singleton
virtual ~NeuroBayesTeacher();
//
// Logging and error handling
common_t* com;
// singleton
static NeuroBayesTeacher* instance;
private:
void NB_DEF_WEIGHT_FACTOR();
// status
static unsigned int instanceCounter;
// Constructor private because it is a singleton
NeuroBayesTeacher(ec_t** ec=NULL, int debug=-1, log_func_t log_f=NULL,
void* log_enclosed=NULL, delete_enclosed_func_t log_delete_enclosed=NULL);
// NeuroBayes variables
std::vector<std::string> varnames;
std::vector<int> prepros;
int maxEvent;
int storedEvents;
int weight_mode;
float trainingTarget1;
float trainingTarget2;
float eventWeight;
float eventWeight2;
double wsum;
double w2sum;
//net input/output arrays
std::vector<float> inarray;
//NeuroBayes Expertise
float Expertise[NB_NEXPERTISE];
std::string ExpertiseFileName;
std::string HistosFileName; // file holding histos, etc
std::string CArrayFileName;
bool writeCArray;
std::stringstream ss;
}; //class NeuroBayesTeacher
#endif