ATLAS Offline Software
Loading...
Searching...
No Matches
BDT.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4namespace MVAUtils {
5
6inline float
7BDT::GetResponse() const
8{
9 return (!m_pointers.empty() ? GetResponse(m_pointers) : -9999.);
10}
11
12inline float
13BDT::GetClassification() const
14{
15 return (!m_pointers.empty() ? GetClassification(m_pointers) : -9999.);
16}
17
18inline std::vector<float>
19BDT::GetMultiResponse(unsigned int numClasses) const
20{
21 return (!m_pointers.empty() ? GetMultiResponse(m_pointers, numClasses)
22 : std::vector<float>());
23}
24
25inline std::vector<float>
26BDT::GetValues() const
27{
28 std::vector<float> result;
29 for (float* ptr : m_pointers) {
30 assert(ptr);
31 result.push_back(*ptr);
32 }
33 return result;
34}
35
36inline const std::vector<float*>&
37BDT::GetPointers() const
38{
39 return m_pointers;
40}
41inline void
42BDT::SetPointers(const std::vector<float*>& pointers)
43{
44 m_pointers = pointers;
45}
46inline unsigned int
47BDT::GetNTrees() const
48{
49 return m_forest->GetNTrees();
50}
51inline int
52BDT::GetNVars() const
53{
54 return m_forest->GetNVars();
55}
56inline float
57BDT::GetOffset() const
58{
59 return m_forest->GetOffset();
60}
61
62/** Return offset + the sum of the response of each tree **/
63inline float
64BDT::GetResponse(const std::vector<float>& values) const
65{
66 return m_forest->GetResponse(values);
67}
68
69/** Return offset + the sum of the response of each tree **/
70inline float
71BDT::GetResponse(const std::vector<float*>& pointers) const
72{
73 return m_forest->GetResponse(pointers);
74}
75
76inline float
77BDT::GetClassification(const std::vector<float>& values) const
78{
79 return m_forest->GetClassification(values);
80}
81
82inline float
83BDT::GetClassification(const std::vector<float*>& pointers) const
84{
85 return m_forest->GetClassification(pointers);
86}
87
88inline float
89BDT::GetGradBoostMVA(const std::vector<float>& values) const
90{
91 const float sum = m_forest->GetRawResponse(values); // ignores the offset
92 return 2. / (1 + std::exp(-2 * sum)) -
93 1; // output shaping for gradient boosted decision tree (-1,1)
94}
95
96inline float
97BDT::GetGradBoostMVA(const std::vector<float*>& pointers) const
98{
99 const float sum = m_forest->GetRawResponse(pointers); // ignores the offset
100 // output shaping for gradient boosted decision tree (-1,1)
101 return 2. / (1 + std::exp(-2 * sum)) - 1;
102}
103
104inline std::vector<float>
105BDT::GetMultiResponse(const std::vector<float>& values,
106 unsigned int numClasses) const
107{
108 return m_forest->GetMultiResponse(values, numClasses);
109}
110
111inline std::vector<float>
112BDT::GetMultiResponse(const std::vector<float*>& pointers,
113 unsigned int numClasses) const
114{
115 return m_forest->GetMultiResponse(pointers, numClasses);
116}
117
118inline float
119BDT::GetTreeResponse(const std::vector<float>& values,
120 MVAUtils::index_t index) const
121{
122 return m_forest->GetTreeResponse(values, index);
123}
124
125inline float
126BDT::GetTreeResponse(const std::vector<float*>& pointers,
127 MVAUtils::index_t index) const
128{
129 return m_forest->GetTreeResponse(pointers, index);
130}
131
132}