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 53 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 65 of file conifer.h.

65  {
66  /* Do the prediction */
67  int i = 0;
68  while (m_feature[i] != -2) { // continue until reaching leaf
69  bool comparison = x[m_feature[i]] <= m_threshold_[i];
70  i = comparison ? m_children_left[i] : m_children_right[i];
71  }
72  return m_value_[i];
73  }

◆ init_()

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

Definition at line 75 of file conifer.h.

75  {
76  /* Since T, U types may not be readable from the JSON, read them to double
77  * and the cast them here */
78  std::transform(m_threshold.begin(), m_threshold.end(),
79  std::back_inserter(m_threshold_),
80  [](double t) -> T { return (T)t; });
81  std::transform(m_value.begin(), m_value.end(), std::back_inserter(m_value_),
82  [](double v) -> U { return (U)v; });
83  }

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 86 of file conifer.h.

86  {
87  j.at("feature").get_to(o.m_feature);
88  j.at("children_left").get_to(o.m_children_left);
89  j.at("children_right").get_to(o.m_children_right);
90  j.at("threshold").get_to(o.m_threshold);
91  j.at("value").get_to(o.m_value);
92  }

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 57 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 58 of file conifer.h.

◆ m_feature

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

Definition at line 56 of file conifer.h.

◆ m_threshold

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

Definition at line 61 of file conifer.h.

◆ m_threshold_

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

Definition at line 59 of file conifer.h.

◆ m_value

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

Definition at line 62 of file conifer.h.

◆ m_value_

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

Definition at line 60 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:59
conifer::DecisionTree::m_threshold
std::vector< double > m_threshold
Definition: conifer.h:61
conifer::DecisionTree::m_feature
std::vector< int > m_feature
Definition: conifer.h:56
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
conifer::DecisionTree::m_value
std::vector< double > m_value
Definition: conifer.h:62
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:60
conifer::DecisionTree::m_children_right
std::vector< int > m_children_right
Definition: conifer.h:58
conifer::DecisionTree::m_children_left
std::vector< int > m_children_left
Definition: conifer.h:57
python.PyAthena.v
v
Definition: PyAthena.py:154