CMS 3D CMS Logo

Forest.h
Go to the documentation of this file.
1 // Forest.h
2 
3 #ifndef L1Trigger_L1TMuonEndCap_emtf_Forest
4 #define L1Trigger_L1TMuonEndCap_emtf_Forest
5 
6 #include "Tree.h"
7 #include "LossFunctions.h"
9 
10 namespace emtf {
11 
12  class Forest {
13  public:
14  // Constructor(s)/Destructor
15  Forest();
16  Forest(std::vector<Event*>& trainingEvents);
17  ~Forest();
18 
19  Forest(const Forest& forest);
20  Forest& operator=(const Forest& forest);
21  Forest(Forest&& forest) = default;
22 
23  // Get/Set
24  void setTrainingEvents(std::vector<Event*>& trainingEvents);
25  std::vector<Event*> getTrainingEvents();
26 
27  // Returns the number of trees in the forest.
28  unsigned int size();
29 
30  // Get info on variable importance.
31  void rankVariables(std::vector<int>& rank);
32 
33  // Output the list of split values used for each variable.
34  void saveSplitValues(const char* savefilename);
35 
36  // Helpful operations
37  void listEvents(std::vector<std::vector<Event*> >& e);
38  void sortEventVectors(std::vector<std::vector<Event*> >& e);
39  void generate(int numTrainEvents, int numTestEvents, double sigma);
40  void loadForestFromXML(const char* directory, unsigned int numTrees);
42 
43  // Perform the regression
44  void updateRegTargets(Tree* tree, double learningRate, LossFunction* l);
45  void doRegression(int nodeLimit,
46  int treeLimit,
47  double learningRate,
48  LossFunction* l,
49  const char* savetreesdirectory,
50  bool saveTrees);
51 
52  // Stochastic Gradient Boosting
53  void prepareRandomSubsample(double fraction);
54  void doStochasticRegression(int nodeLimit, int treeLimit, double learningRate, double fraction, LossFunction* l);
55 
56  // Predict some events
57  void updateEvents(Tree* tree);
58  void appendCorrection(std::vector<Event*>& eventsp, int treenum);
59  void predictEvents(std::vector<Event*>& eventsp, unsigned int trees);
60  void appendCorrection(Event* e, int treenum);
61  void predictEvent(Event* e, unsigned int trees);
62 
63  Tree* getTree(unsigned int i);
64 
65  private:
66  std::vector<std::vector<Event*> > events;
67  std::vector<std::vector<Event*> > subSample;
68  std::vector<Tree*> trees;
69  };
70 
71 } // namespace emtf
72 
73 #endif
emtf::Forest::loadFromCondPayload
void loadFromCondPayload(const L1TMuonEndCapForest::DForest &payload)
Definition: Forest.cc:497
emtf::Forest::~Forest
~Forest()
Definition: Forest.cc:52
emtf::Forest::updateEvents
void updateEvents(Tree *tree)
Definition: Forest.cc:328
mps_fire.i
i
Definition: mps_fire.py:428
emtf::Tree
Definition: Tree.h:15
emtf::Forest::rankVariables
void rankVariables(std::vector< int > &rank)
Definition: Forest.cc:195
emtf::Forest::updateRegTargets
void updateRegTargets(Tree *tree, double learningRate, LossFunction *l)
Definition: Forest.cc:289
emtf::Forest::generate
void generate(int numTrainEvents, int numTestEvents, double sigma)
tree
Definition: tree.py:1
emtf::Forest::listEvents
void listEvents(std::vector< std::vector< Event * > > &e)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Definition: Forest.cc:142
emtf::Forest::predictEvent
void predictEvent(Event *e, unsigned int trees)
Definition: Forest.cc:440
emtf::Forest::getTrainingEvents
std::vector< Event * > getTrainingEvents()
Definition: Forest.cc:107
emtf::LossFunction
Definition: LossFunctions.h:20
emtf::Forest::predictEvents
void predictEvents(std::vector< Event * > &eventsp, unsigned int trees)
Definition: Forest.cc:406
emtf::Event
Definition: Event.h:17
emtf::Forest::saveSplitValues
void saveSplitValues(const char *savefilename)
Definition: Forest.cc:245
emtf::Forest::operator=
Forest & operator=(const Forest &forest)
Definition: Forest.cc:70
HLT_FULL_cff.fraction
fraction
Definition: HLT_FULL_cff.py:52802
emtf::Forest::loadForestFromXML
void loadForestFromXML(const char *directory, unsigned int numTrees)
Definition: Forest.cc:477
emtf
Definition: Event.h:15
emtf::Forest::size
unsigned int size()
Definition: Forest.cc:127
jets_cff.payload
payload
Definition: jets_cff.py:32
emtf::Forest::appendCorrection
void appendCorrection(std::vector< Event * > &eventsp, int treenum)
Definition: Forest.cc:426
emtf::Forest::sortEventVectors
void sortEventVectors(std::vector< std::vector< Event * > > &e)
Definition: Forest.cc:181
emtf::Forest::getTree
Tree * getTree(unsigned int i)
Definition: Forest.cc:114
L1TMuonEndCapForest.h
emtf::Forest::doStochasticRegression
void doStochasticRegression(int nodeLimit, int treeLimit, double learningRate, double fraction, LossFunction *l)
Definition: Forest.cc:548
LossFunctions.h
emtf::Forest::prepareRandomSubsample
void prepareRandomSubsample(double fraction)
Definition: Forest.cc:521
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
emtf::Forest::events
std::vector< std::vector< Event * > > events
Definition: Forest.h:66
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
emtf::Forest
Definition: Forest.h:12
emtf::Forest::trees
std::vector< Tree * > trees
Definition: Forest.h:68
Tree.h
L1TMuonEndCapForest::DForest
std::vector< DTree > DForest
Definition: L1TMuonEndCapForest.h:32
createBeamHaloJobs.directory
string directory
Definition: createBeamHaloJobs.py:211
emtf::Forest::setTrainingEvents
void setTrainingEvents(std::vector< Event * > &trainingEvents)
Definition: Forest.cc:87
emtf::Forest::Forest
Forest()
Definition: Forest.cc:40
emtf::Forest::subSample
std::vector< std::vector< Event * > > subSample
Definition: Forest.h:67
emtf::Forest::doRegression
void doRegression(int nodeLimit, int treeLimit, double learningRate, LossFunction *l, const char *savetreesdirectory, bool saveTrees)
Definition: Forest.cc:355
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37