1 |
bendavid |
1.1 |
|
2 |
|
|
#ifndef ROOT_GBRForest
|
3 |
|
|
#define ROOT_GBRForest
|
4 |
|
|
|
5 |
|
|
//////////////////////////////////////////////////////////////////////////
|
6 |
|
|
// //
|
7 |
|
|
// GBRForest //
|
8 |
|
|
// //
|
9 |
|
|
// A fast minimal implementation of Gradient-Boosted Regression Trees //
|
10 |
|
|
// which has been especially optimized for size on disk and in memory. //
|
11 |
|
|
// //
|
12 |
|
|
// Designed to built from TMVA-trained trees, but could also be //
|
13 |
|
|
// generalized to otherwise-trained trees, classification, //
|
14 |
|
|
// or other boosting methods in the future //
|
15 |
|
|
// //
|
16 |
|
|
// Josh Bendavid - MIT //
|
17 |
|
|
//////////////////////////////////////////////////////////////////////////
|
18 |
|
|
|
19 |
|
|
#include "TNamed.h"
|
20 |
|
|
#include <vector>
|
21 |
|
|
#include "GBRTree.h"
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
namespace TMVA {
|
25 |
|
|
class MethodBDT;
|
26 |
|
|
}
|
27 |
|
|
|
28 |
|
|
class GBRForest : public TNamed {
|
29 |
|
|
|
30 |
|
|
public:
|
31 |
|
|
|
32 |
|
|
GBRForest();
|
33 |
|
|
GBRForest(const TMVA::MethodBDT *bdt);
|
34 |
|
|
virtual ~GBRForest();
|
35 |
|
|
|
36 |
|
|
Double_t GetResponse(const Float_t* vector) const;
|
37 |
|
|
|
38 |
|
|
std::vector<GBRTree*> &Trees() { return fTrees; }
|
39 |
|
|
|
40 |
|
|
protected:
|
41 |
|
|
Double_t fInitialResponse;
|
42 |
|
|
std::vector<GBRTree*> fTrees;
|
43 |
|
|
|
44 |
|
|
ClassDef(GBRForest,1) // Node for the Decision Tree
|
45 |
|
|
};
|
46 |
|
|
|
47 |
|
|
//_______________________________________________________________________
|
48 |
|
|
inline Double_t GBRForest::GetResponse(const Float_t* vector) const {
|
49 |
|
|
Double_t response = fInitialResponse;
|
50 |
|
|
for (std::vector<GBRTree*>::const_iterator it=fTrees.begin(); it!=fTrees.end(); ++it) {
|
51 |
|
|
response += (*it)->GetResponse(vector);
|
52 |
|
|
}
|
53 |
|
|
return response;
|
54 |
|
|
}
|
55 |
|
|
|
56 |
|
|
#endif
|