1 #ifndef L1TRIGGER_PHASE2L1PARTICLEFLOW_CONNIFER_H 2 #define L1TRIGGER_PHASE2L1PARTICLEFLOW_CONNIFER_H 3 #include "nlohmann/json.hpp" 24 constexpr
int pow(
int x) {
25 return x == 0 ? 1 :
B * pow<B>(
x - 1);
28 constexpr
int pow2(
int x) {
return pow<2>(
x); }
30 template <
class T,
class Op>
38 return op(
x.at(0),
x.at(1));
40 std::vector<T> left(
x.begin(),
x.begin() + leftN);
41 std::vector<T> right(
x.begin() + leftN,
x.end());
42 return op(reduce<T, Op>(left,
op), reduce<T, Op>(right,
op));
52 template <
class T,
class U>
86 template <
class T,
class U,
bool useAddTree = false>
95 std::vector<std::vector<DecisionTree<T, U>>>
trees;
122 #ifdef CMSSW_GIT_HASH 125 <<
"Conifer : Size of feature vector mismatches expected n_features" << std::endl;
129 throw std::runtime_error(
"Conifer : Size of feature vector mismatches expected n_features");
133 std::vector<std::vector<U>> values_trees;
139 std::back_inserter(values_trees.at(
i)),
143 values.at(
i) += reduce<U, OpAdd<U>>(values_trees.at(
i),
add);
157 std::vector<double> yd;
158 std::transform(y.begin(), y.end(), std::back_inserter(yd), [](
U yi) ->
double {
return (
double)yi; });
vector< string > parse(string line, const string &delimiter)
std::vector< int > feature
std::vector< double > value
std::vector< double > init_predict
std::vector< T > threshold_
std::vector< int > children_right
T reduce(std::vector< T > x, Op op)
std::vector< U > decision_function(std::vector< T > x) const
constexpr int floorlog2(int x)
std::vector< double > threshold
BDT(std::string filename)
NLOHMANN_DEFINE_TYPE_INTRUSIVE(BDT, n_classes, n_trees, n_features, init_predict, trees)
std::vector< U > init_predict_
void from_json(const nlohmann::json &nlohmann_json_j, mkfit::LayerControl &nlohmann_json_t)
constexpr int pow2(int x)
NLOHMANN_DEFINE_TYPE_INTRUSIVE(DecisionTree, feature, children_left, children_right, threshold, value)
std::vector< std::vector< DecisionTree< T, U > > > trees
std::vector< int > children_left
std::vector< double > _decision_function_double(std::vector< double > x) const
U decision_function(std::vector< T > x) const