ATLAS Offline Software
Loading...
Searching...
No Matches
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];
71 }
72 return m_value_[i];
73 }
std::vector< int > m_feature
Definition conifer.h:56
std::vector< int > m_children_right
Definition conifer.h:58
std::vector< U > m_value_
Definition conifer.h:60
std::vector< T > m_threshold_
Definition conifer.h:59
std::vector< int > m_children_left
Definition conifer.h:57

◆ 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 */
80 [](double t) -> T { return (T)t; });
82 [](double v) -> U { return (U)v; });
83 }
std::vector< double > m_threshold
Definition conifer.h:61
std::vector< double > m_value
Definition conifer.h:62

◆ 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: