ATLAS Offline Software
Public Member Functions | Private Attributes | Friends | List of all members
conifer::DecisionTree< T, U > Class Template Reference

#include <conifer.h>

Collaboration diagram for conifer::DecisionTree< T, U >:

Public Member Functions

decision_function (const std::vector< T > &x) const
 
void init_ ()
 

Private Attributes

std::vector< int > m_feature
 
std::vector< int > m_children_left
 
std::vector< int > m_children_right
 
std::vector< T > m_threshold_
 
std::vector< U > m_value_
 
std::vector< double > m_threshold
 
std::vector< double > m_value
 

Friends

void from_json (const nlohmann::json &j, DecisionTree &o)
 

Detailed Description

template<class T, class U>
class conifer::DecisionTree< T, U >

Definition at line 46 of file conifer.h.

Member Function Documentation

◆ decision_function()

template<class T , class U >
U conifer::DecisionTree< T, U >::decision_function ( const std::vector< T > &  x) const
inline

Definition at line 58 of file conifer.h.

58  {
59  /* Do the prediction */
60  int i = 0;
61  while (m_feature[i] != -2) { // continue until reaching leaf
62  bool comparison = x[m_feature[i]] <= m_threshold_[i];
63  i = comparison ? m_children_left[i] : m_children_right[i];
64  }
65  return m_value_[i];
66  }

◆ init_()

template<class T , class U >
void conifer::DecisionTree< T, U >::init_ ( )
inline

Definition at line 68 of file conifer.h.

68  {
69  /* Since T, U types may not be readable from the JSON, read them to double
70  * and the cast them here */
71  std::transform(m_threshold.begin(), m_threshold.end(),
72  std::back_inserter(m_threshold_),
73  [](double t) -> T { return (T)t; });
74  std::transform(m_value.begin(), m_value.end(), std::back_inserter(m_value_),
75  [](double v) -> U { return (U)v; });
76  }

Friends And Related Function Documentation

◆ from_json

template<class T , class U >
void from_json ( const nlohmann::json j,
DecisionTree< T, U > &  o 
)
friend

Definition at line 79 of file conifer.h.

79  {
80  j.at("feature").get_to(o.m_feature);
81  j.at("children_left").get_to(o.m_children_left);
82  j.at("children_right").get_to(o.m_children_right);
83  j.at("threshold").get_to(o.m_threshold);
84  j.at("value").get_to(o.m_value);
85  }

Member Data Documentation

◆ m_children_left

template<class T , class U >
std::vector<int> conifer::DecisionTree< T, U >::m_children_left
private

Definition at line 50 of file conifer.h.

◆ m_children_right

template<class T , class U >
std::vector<int> conifer::DecisionTree< T, U >::m_children_right
private

Definition at line 51 of file conifer.h.

◆ m_feature

template<class T , class U >
std::vector<int> conifer::DecisionTree< T, U >::m_feature
private

Definition at line 49 of file conifer.h.

◆ m_threshold

template<class T , class U >
std::vector<double> conifer::DecisionTree< T, U >::m_threshold
private

Definition at line 54 of file conifer.h.

◆ m_threshold_

template<class T , class U >
std::vector<T> conifer::DecisionTree< T, U >::m_threshold_
private

Definition at line 52 of file conifer.h.

◆ m_value

template<class T , class U >
std::vector<double> conifer::DecisionTree< T, U >::m_value
private

Definition at line 55 of file conifer.h.

◆ m_value_

template<class T , class U >
std::vector<U> conifer::DecisionTree< T, U >::m_value_
private

Definition at line 53 of file conifer.h.


The documentation for this class was generated from the following file:
conifer::DecisionTree::m_threshold_
std::vector< T > m_threshold_
Definition: conifer.h:52
conifer::DecisionTree::m_threshold
std::vector< double > m_threshold
Definition: conifer.h:54
conifer::DecisionTree::m_feature
std::vector< int > m_feature
Definition: conifer.h:49
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
conifer::DecisionTree::m_value
std::vector< double > m_value
Definition: conifer.h:55
x
#define x
lumiFormat.i
int i
Definition: lumiFormat.py:85
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
conifer::DecisionTree::m_value_
std::vector< U > m_value_
Definition: conifer.h:53
conifer::DecisionTree::m_children_right
std::vector< int > m_children_right
Definition: conifer.h:51
conifer::DecisionTree::m_children_left
std::vector< int > m_children_left
Definition: conifer.h:50
python.PyAthena.v
v
Definition: PyAthena.py:154