test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Forest.h
Go to the documentation of this file.
1 // Forest.h
2 
3 #ifndef L1Trigger_L1TMuonEndCap_Forest
4 #define L1Trigger_L1TMuonEndCap_Forest
5 
8 
9 class L1TForest
10 {
11  public:
12 
13  // Constructor(s)/Destructor
14  L1TForest();
15  L1TForest(std::vector<emtf::Event*>& trainingEvents);
16  ~L1TForest();
17 
18  // Get/Set
19  void setTrainingEvents(std::vector<emtf::Event*>& trainingEvents);
20  std::vector<emtf::Event*> getTrainingEvents();
21 
22  // Returns the number of trees in the forest.
23  unsigned int size();
24 
25  // Get info on variable importance.
26  void rankVariables(std::vector<int>& rank);
27 
28  // Output the list of split values used for each variable.
29  void saveSplitValues(const char* savefilename);
30 
31  // Helpful operations
32  void listEvents(std::vector< std::vector<emtf::Event*> >& e);
33  void sortEventVectors(std::vector< std::vector<emtf::Event*> >& e);
34  void generate(Int_t numTrainEvents, Int_t numTestEvents, double sigma);
35  void loadL1TForestFromXML(const char* directory, unsigned int numTrees);
36 
37  // Perform the regression
38  void updateRegTargets(emtf::Tree *tree, double learningRate, L1TLossFunction* l);
39  void doRegression(Int_t nodeLimit, Int_t treeLimit, double learningRate, L1TLossFunction* l,
40  const char* savetreesdirectory, bool saveTrees);
41 
42  // Stochastic Gradient Boosting
43  void prepareRandomSubsample(double fraction);
44  void doStochasticRegression(Int_t nodeLimit, Int_t treeLimit, double learningRate,
45  double fraction, L1TLossFunction* l);
46 
47  // Predict some events
48  void updateEvents(emtf::Tree* tree);
49  void appendCorrection(std::vector<emtf::Event*>& eventsp, Int_t treenum);
50  void predictEvents(std::vector<emtf::Event*>& eventsp, unsigned int trees);
51  void appendCorrection(emtf::Event* e, Int_t treenum);
52  void predictEvent(emtf::Event* e, unsigned int trees);
53 
54  emtf::Tree* getTree(unsigned int i);
55 
56  private:
57 
58  std::vector< std::vector<emtf::Event*> > events;
59  std::vector< std::vector<emtf::Event*> > subSample;
60  std::vector<emtf::Tree*> trees;
61 };
62 
63 #endif
int i
Definition: DBlmapReader.cc:9
std::vector< emtf::Event * > getTrainingEvents()
Definition: Forest.cc:94
void setTrainingEvents(std::vector< emtf::Event * > &trainingEvents)
Definition: Forest.cc:70
void predictEvents(std::vector< emtf::Event * > &eventsp, unsigned int trees)
Definition: Forest.cc:413
void updateRegTargets(emtf::Tree *tree, double learningRate, L1TLossFunction *l)
Definition: Forest.cc:294
void prepareRandomSubsample(double fraction)
Definition: Forest.cc:516
void rankVariables(std::vector< int > &rank)
Definition: Forest.cc:191
void generate(Int_t numTrainEvents, Int_t numTestEvents, double sigma)
unsigned int size()
Definition: Forest.cc:115
void doRegression(Int_t nodeLimit, Int_t treeLimit, double learningRate, L1TLossFunction *l, const char *savetreesdirectory, bool saveTrees)
Definition: Forest.cc:366
void loadL1TForestFromXML(const char *directory, unsigned int numTrees)
Definition: Forest.cc:489
std::vector< emtf::Tree * > trees
Definition: Forest.h:60
void doStochasticRegression(Int_t nodeLimit, Int_t treeLimit, double learningRate, double fraction, L1TLossFunction *l)
Definition: Forest.cc:545
emtf::Tree * getTree(unsigned int i)
Definition: Forest.cc:101
std::vector< std::vector< emtf::Event * > > subSample
Definition: Forest.h:59
void updateEvents(emtf::Tree *tree)
Definition: Forest.cc:336
~L1TForest()
Definition: Forest.cc:54
std::vector< std::vector< emtf::Event * > > events
Definition: Forest.h:58
L1TForest()
Definition: Forest.cc:36
void sortEventVectors(std::vector< std::vector< emtf::Event * > > &e)
Definition: Forest.cc:175
void listEvents(std::vector< std::vector< emtf::Event * > > &e)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Definition: Forest.cc:131
void predictEvent(emtf::Event *e, unsigned int trees)
Definition: Forest.cc:451
void appendCorrection(std::vector< emtf::Event * > &eventsp, Int_t treenum)
Definition: Forest.cc:436
void saveSplitValues(const char *savefilename)
Definition: Forest.cc:246