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 ADD_FOREST
4 #define ADD_FOREST
5 
8 
9 class Forest
10 {
11  public:
12 
13  // Constructor(s)/Destructor
14  Forest();
15  Forest(std::vector<Event*>& trainingEvents, std::vector<Event*>& testEvents);
16  ~Forest();
17 
18  // Get/Set
19  void setTrainingEvents(std::vector<Event*>& trainingEvents);
20  void setTestEvents(std::vector<Event*>& testingEvents);
21  std::vector<Event*> getTrainingEvents();
22  std::vector<Event*> getTestEvents();
23 
24  // Returns the number of trees in the forest.
25  unsigned int size();
26 
27  // Get info on variable importance.
28  std::vector<Double_t> rankVariables();
29 
30  // Helpful operations
31  void listEvents(std::vector< std::vector<Event*> >& e);
32  void sortEventVectors(std::vector< std::vector<Event*> >& e);
33  void generate(Int_t numTrainEvents, Int_t numTestEvents, Double_t sigma);
34  void loadForestFromXML(const char* directory, unsigned int numTrees);
35 
36  // Perform the regression
37  void updateRegTargets(Tree *tree, Double_t learningRate, LossFunction* l);
38  void doRegression(Int_t nodeLimit, Int_t treeLimit, Double_t learningRate, LossFunction* l,
39  const char* savetreesdirectory, bool saveTrees);
40 
41  // Stochastic Gradient Boosting
42  void prepareRandomSubsample(Double_t fraction);
43  void doStochasticRegression(Int_t nodeLimit, Int_t treeLimit, Double_t learningRate,
44  Double_t fraction, LossFunction* l);
45 
46  // Predict some events
47  void updateEvents(Tree* tree);
48  void appendCorrection(std::vector<Event*> eventsp, Int_t treenum);
49  void predictEvents(std::vector<Event*> eventsp, unsigned int trees);
50 
51  private:
52 
53  std::vector< std::vector<Event*> > events;
54  std::vector< std::vector<Event*> > subSample;
55  std::vector<Event*> testEvents;
56  std::vector<Tree*> trees;
57 };
58 
59 #endif
void generate(Int_t numTrainEvents, Int_t numTestEvents, Double_t sigma)
Definition: Forest.cc:531
void prepareRandomSubsample(Double_t fraction)
Definition: Forest.cc:446
Forest()
Definition: Forest.cc:42
std::vector< std::vector< Event * > > events
Definition: Forest.h:53
std::vector< Event * > getTestEvents()
Definition: Forest.cc:125
std::vector< Event * > testEvents
Definition: Forest.h:55
void appendCorrection(std::vector< Event * > eventsp, Int_t treenum)
Definition: Forest.cc:405
void predictEvents(std::vector< Event * > eventsp, unsigned int trees)
Definition: Forest.cc:382
void loadForestFromXML(const char *directory, unsigned int numTrees)
Definition: Forest.cc:420
std::vector< Double_t > rankVariables()
Definition: Forest.cc:207
~Forest()
Definition: Forest.cc:61
void updateEvents(Tree *tree)
Definition: Forest.cc:305
void doStochasticRegression(Int_t nodeLimit, Int_t treeLimit, Double_t learningRate, Double_t fraction, LossFunction *l)
Definition: Forest.cc:475
Definition: Tree.h:16
void sortEventVectors(std::vector< std::vector< Event * > > &e)
Definition: Forest.cc:191
void updateRegTargets(Tree *tree, Double_t learningRate, LossFunction *l)
Definition: Forest.cc:263
std::vector< Tree * > trees
Definition: Forest.h:56
std::vector< std::vector< Event * > > subSample
Definition: Forest.h:54
Definition: Forest.h:9
void listEvents(std::vector< std::vector< Event * > > &e)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Definition: Forest.cc:147
unsigned int size()
Definition: Forest.cc:131
void setTrainingEvents(std::vector< Event * > &trainingEvents)
Definition: Forest.cc:87
std::vector< Event * > getTrainingEvents()
Definition: Forest.cc:118
void doRegression(Int_t nodeLimit, Int_t treeLimit, Double_t learningRate, LossFunction *l, const char *savetreesdirectory, bool saveTrees)
Definition: Forest.cc:335
void setTestEvents(std::vector< Event * > &testingEvents)
Definition: Forest.cc:107