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);
16  ~Forest();
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 loadForestFromXML(const char* directory, unsigned int numTrees);
36 
37  // Perform the regression
38  void updateRegTargets(Tree *tree, double learningRate, LossFunction* l);
39  void doRegression(Int_t nodeLimit, Int_t treeLimit, double learningRate, LossFunction* 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, LossFunction* 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
Forest()
Definition: Forest.cc:34
void doRegression(Int_t nodeLimit, Int_t treeLimit, double learningRate, LossFunction *l, const char *savetreesdirectory, bool saveTrees)
Definition: Forest.cc:362
std::vector< std::vector< Event * > > events
Definition: Forest.h:58
void saveSplitValues(const char *savefilename)
Definition: Forest.cc:242
void predictEvents(std::vector< Event * > &eventsp, unsigned int trees)
Definition: Forest.cc:409
void predictEvent(Event *e, unsigned int trees)
Definition: Forest.cc:447
Tree * getTree(unsigned int i)
Definition: Forest.cc:97
void doStochasticRegression(Int_t nodeLimit, Int_t treeLimit, double learningRate, double fraction, LossFunction *l)
Definition: Forest.cc:541
Definition: Event.h:16
void loadForestFromXML(const char *directory, unsigned int numTrees)
Definition: Forest.cc:485
void generate(Int_t numTrainEvents, Int_t numTestEvents, double sigma)
~Forest()
Definition: Forest.cc:52
void updateEvents(Tree *tree)
Definition: Forest.cc:332
Definition: Tree.h:17
void sortEventVectors(std::vector< std::vector< Event * > > &e)
Definition: Forest.cc:171
void updateRegTargets(Tree *tree, double learningRate, LossFunction *l)
Definition: Forest.cc:290
std::vector< Tree * > trees
Definition: Forest.h:60
std::vector< std::vector< Event * > > subSample
Definition: Forest.h:59
Definition: Forest.h:9
void listEvents(std::vector< std::vector< Event * > > &e)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Definition: Forest.cc:127
unsigned int size()
Definition: Forest.cc:111
void appendCorrection(std::vector< Event * > &eventsp, Int_t treenum)
Definition: Forest.cc:432
void rankVariables(std::vector< int > &rank)
Definition: Forest.cc:187
void setTrainingEvents(std::vector< Event * > &trainingEvents)
Definition: Forest.cc:68
std::vector< Event * > getTrainingEvents()
Definition: Forest.cc:90
void prepareRandomSubsample(double fraction)
Definition: Forest.cc:512