Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TMVA::Experimental::RBDT Class Referencefinal

Definition at line 35 of file RBDT.hxx.

Public Types

typedef float Value_t
 

Public Member Functions

template<typename Vector >
Vector Compute (const Vector &x) const
 Compute model prediction on a single event.
 
std::vector< Value_t > Compute (std::span< const Value_t > x, unsigned int cols) const
 Compute model prediction on a flat batch of events.
 
std::vector< Value_t > Compute (std::vector< Value_t > const &x) const
 Compute model prediction on a single event.
 

Static Public Member Functions

static RBDT LoadXGBoost (std::string const &jsonPath)
 Construct an RBDT from an XGBoost model in its native JSON serialization.
 

Private Types

using IndexMap = std::unordered_map<int, int>
 Map from XGBoost to RBDT indices.
 

Private Member Functions

 RBDT ()=default
 Private default constructor, used by the public LoadXGBoost() factory.
 
void ComputeImpl (const Value_t *array, Value_t *out) const
 
Value_t EvaluateBinary (const Value_t *array) const
 
void Softmax (const Value_t *array, Value_t *out) const
 

Static Private Member Functions

static void correctIndices (std::span< int > indices, IndexMap const &nodeIndices, IndexMap const &leafIndices)
 RBDT uses a more efficient representation of the BDT in flat arrays.
 
static void terminateTree (TMVA::Experimental::RBDT &ff, int &nPreviousNodes, int &nPreviousLeaves, IndexMap &nodeIndices, IndexMap &leafIndices, int &treesSkipped)
 

Private Attributes

std::vector< Value_t > fBaseResponses
 
Value_t fBaseScore = 0.0
 
std::vector< unsigned int > fCutIndices
 
std::vector< Value_t > fCutValues
 
std::vector< int > fLeftIndices
 
bool fLogistic = false
 
std::vector< Value_t > fResponses
 
std::vector< int > fRightIndices
 
std::vector< int > fRootIndices
 
std::vector< int > fTreeNumbers
 

#include <TMVA/RBDT.hxx>

Member Typedef Documentation

◆ IndexMap

using TMVA::Experimental::RBDT::IndexMap = std::unordered_map<int, int>
private

Map from XGBoost to RBDT indices.

Definition at line 71 of file RBDT.hxx.

◆ Value_t

Definition at line 37 of file RBDT.hxx.

Constructor & Destructor Documentation

◆ RBDT()

TMVA::Experimental::RBDT::RBDT ( )
privatedefault

Private default constructor, used by the public LoadXGBoost() factory.

Member Function Documentation

◆ Compute() [1/3]

template<typename Vector >
Vector TMVA::Experimental::RBDT::Compute ( const Vector & x) const
inline

Compute model prediction on a single event.

The method is intended to be used with std::vectors-like containers, for example RVecs.

Definition at line 44 of file RBDT.hxx.

◆ Compute() [2/3]

std::vector< TMVA::Experimental::RBDT::Value_t > TMVA::Experimental::RBDT::Compute ( std::span< const Value_t > x,
unsigned int cols ) const

Compute model prediction on a flat batch of events.

The input must be flat row-major with cols features per event and the output is a flat row-major vector with one row of outputs per event, contiguous at y[row * nOut + k]. nOut is the number of model output values per event: one for regression and binary classification models, the number of classes for multiclass ones.

Definition at line 98 of file RBDT.cxx.

◆ Compute() [3/3]

std::vector< Value_t > TMVA::Experimental::RBDT::Compute ( std::vector< Value_t > const & x) const
inline

Compute model prediction on a single event.

Definition at line 53 of file RBDT.hxx.

◆ ComputeImpl()

void TMVA::Experimental::RBDT::ComputeImpl ( const Value_t * array,
Value_t * out ) const
private

Definition at line 141 of file RBDT.cxx.

◆ correctIndices()

void TMVA::Experimental::RBDT::correctIndices ( std::span< int > indices,
IndexMap const & nodeIndices,
IndexMap const & leafIndices )
staticprivate

RBDT uses a more efficient representation of the BDT in flat arrays.

This function translates the indices to the RBDT indices. In RBDT, leaf nodes are stored in separate arrays. To encode this, the sign of the index is flipped.

Definition at line 176 of file RBDT.cxx.

◆ EvaluateBinary()

TMVA::Experimental::RBDT::Value_t TMVA::Experimental::RBDT::EvaluateBinary ( const Value_t * array) const
private

Definition at line 154 of file RBDT.cxx.

◆ LoadXGBoost()

TMVA::Experimental::RBDT TMVA::Experimental::RBDT::LoadXGBoost ( std::string const & jsonPath)
static

Construct an RBDT from an XGBoost model in its native JSON serialization.

This reads the structured model that XGBoost writes with Booster.save_model(). That format stores each tree as a set of parallel arrays and references features by index, so no feature-name resolution is needed. Everything else (objective, base score, number of classes) is taken from the file, which makes this a self-contained, Python-free entry point.

Definition at line 226 of file RBDT.cxx.

◆ Softmax()

void TMVA::Experimental::RBDT::Softmax ( const Value_t * array,
Value_t * out ) const
private

Definition at line 114 of file RBDT.cxx.

◆ terminateTree()

void TMVA::Experimental::RBDT::terminateTree ( TMVA::Experimental::RBDT & ff,
int & nPreviousNodes,
int & nPreviousLeaves,
IndexMap & nodeIndices,
IndexMap & leafIndices,
int & treesSkipped )
staticprivate

Definition at line 197 of file RBDT.cxx.

Member Data Documentation

◆ fBaseResponses

std::vector<Value_t> TMVA::Experimental::RBDT::fBaseResponses
private

Definition at line 87 of file RBDT.hxx.

◆ fBaseScore

Value_t TMVA::Experimental::RBDT::fBaseScore = 0.0
private

Definition at line 88 of file RBDT.hxx.

◆ fCutIndices

std::vector<unsigned int> TMVA::Experimental::RBDT::fCutIndices
private

Definition at line 81 of file RBDT.hxx.

◆ fCutValues

std::vector<Value_t> TMVA::Experimental::RBDT::fCutValues
private

Definition at line 82 of file RBDT.hxx.

◆ fLeftIndices

std::vector<int> TMVA::Experimental::RBDT::fLeftIndices
private

Definition at line 83 of file RBDT.hxx.

◆ fLogistic

bool TMVA::Experimental::RBDT::fLogistic = false
private

Definition at line 89 of file RBDT.hxx.

◆ fResponses

std::vector<Value_t> TMVA::Experimental::RBDT::fResponses
private

Definition at line 85 of file RBDT.hxx.

◆ fRightIndices

std::vector<int> TMVA::Experimental::RBDT::fRightIndices
private

Definition at line 84 of file RBDT.hxx.

◆ fRootIndices

std::vector<int> TMVA::Experimental::RBDT::fRootIndices
private

Definition at line 80 of file RBDT.hxx.

◆ fTreeNumbers

std::vector<int> TMVA::Experimental::RBDT::fTreeNumbers
private

Definition at line 86 of file RBDT.hxx.

Libraries for TMVA::Experimental::RBDT:

The documentation for this class was generated from the following files: