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<Event*>& trainingEvents);
16  ~L1TForest();
17 
18  // Get/Set
19  void setTrainingEvents(std::vector<Event*>& trainingEvents);
20  std::vector<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<Event*> >& e);
33  void sortEventVectors(std::vector< std::vector<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(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(Tree* tree);
49  void appendCorrection(std::vector<Event*>& eventsp, Int_t treenum);
50  void predictEvents(std::vector<Event*>& eventsp, unsigned int trees);
51  void appendCorrection(Event* e, Int_t treenum);
52  void predictEvent(Event* e, unsigned int trees);
53 
54  Tree* getTree(unsigned int i);
55 
56  private:
57 
58  std::vector< std::vector<Event*> > events;
59  std::vector< std::vector<Event*> > subSample;
60  std::vector<Tree*> trees;
61 };
62 
63 #endif
int i
Definition: DBlmapReader.cc:9
std::vector< Event * > getTrainingEvents()
Definition: Forest.cc:92
void prepareRandomSubsample(double fraction)
Definition: Forest.cc:514
void rankVariables(std::vector< int > &rank)
Definition: Forest.cc:189
void generate(Int_t numTrainEvents, Int_t numTestEvents, double sigma)
std::vector< Tree * > trees
Definition: Forest.h:60
unsigned int size()
Definition: Forest.cc:113
void doRegression(Int_t nodeLimit, Int_t treeLimit, double learningRate, L1TLossFunction *l, const char *savetreesdirectory, bool saveTrees)
Definition: Forest.cc:364
void loadL1TForestFromXML(const char *directory, unsigned int numTrees)
Definition: Forest.cc:487
void updateEvents(Tree *tree)
Definition: Forest.cc:334
void doStochasticRegression(Int_t nodeLimit, Int_t treeLimit, double learningRate, double fraction, L1TLossFunction *l)
Definition: Forest.cc:543
Definition: Event.h:16
void listEvents(std::vector< std::vector< Event * > > &e)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Definition: Forest.cc:129
void setTrainingEvents(std::vector< Event * > &trainingEvents)
Definition: Forest.cc:68
void appendCorrection(std::vector< Event * > &eventsp, Int_t treenum)
Definition: Forest.cc:434
~L1TForest()
Definition: Forest.cc:52
std::vector< std::vector< Event * > > events
Definition: Forest.h:58
void sortEventVectors(std::vector< std::vector< Event * > > &e)
Definition: Forest.cc:173
void updateRegTargets(Tree *tree, double learningRate, L1TLossFunction *l)
Definition: Forest.cc:292
Definition: Tree.h:17
std::vector< std::vector< Event * > > subSample
Definition: Forest.h:59
Tree * getTree(unsigned int i)
Definition: Forest.cc:99
L1TForest()
Definition: Forest.cc:34
void predictEvents(std::vector< Event * > &eventsp, unsigned int trees)
Definition: Forest.cc:411
void predictEvent(Event *e, unsigned int trees)
Definition: Forest.cc:449
void saveSplitValues(const char *savefilename)
Definition: Forest.cc:244