Brush C++ API
A flexible interpretable machine learning framework
Loading...
Searching...
No Matches
Brush::Operator< NT, S, Fit, E > Struct Template Reference

Core computation of a node's function to data. More...

#include <operator.h>

Public Types

using ArgTypes
 set argument types to those of the signature unless:
 
using RetType = typename S::RetType
 return type of the operator
 
template<std::size_t N>
using NthType = typename S::NthType<N>
 utility for returning the type of the Nth argument
 
using W = typename S::WeightType
 set weight type
 

Public Member Functions

 Operator ()=default
 
template<typename T = ArgTypes>
requires (is_std_array_v<T> || is_eigen_array_v<T>)
get_kids (const Dataset &d, TreeNode &tn, const W **weights=nullptr) const
 get a std::array or eigen array of kids
 
template<int I>
NthType< Iget_kid (const Dataset &d, TreeNode &tn, const W **weights) const
 gets one kid for a tuple of kids
 
template<typename T , size_t ... Is>
requires (is_tuple_v<T>)
get_kids_seq (const Dataset &d, TreeNode &tn, const W **weights, std::index_sequence< Is... >) const
 Makes and returns a tuple of child outputs.
 
template<typename T = ArgTypes>
requires (is_tuple_v<T>)
get_kids (const Dataset &d, TreeNode &tn, const W **weights=nullptr) const
 get a std::tuple of kids. Used when child arguments are different types.
 
template<typename T = ArgTypes>
requires ( is_std_array_v<T> || is_tuple_v<T>)
RetType apply (const T &inputs) const
 Apply node function in a functional style.
 
template<typename T = ArgTypes>
requires ( is_eigen_array_v<T> && !is_std_array_v<T>)
RetType apply (const T &inputs) const
 Apply the node function like a function.
 
template<typename T = ArgTypes, typename Scalar = RetType::Scalar>
RetType eval (const Dataset &d, TreeNode &tn, const W **weights=nullptr) const
 evaluate the operator on the data. main entry point.
 
template<typename T = ArgTypes, typename Scalar = RetType::Scalar>
requires is_in_v<NT, NodeType::OffsetSum>
RetType eval (const Dataset &d, TreeNode &tn, const W **weights=nullptr) const
 

Static Public Attributes

static constexpr size_t ArgCount = S::ArgCount
 stores the argument count of the operator
 
static constexpr auto F
 wrapper function for the node function
 

Detailed Description

template<NodeType NT, typename S, bool Fit, typename E = void>
struct Brush::Operator< NT, S, Fit, E >

Core computation of a node's function to data.

Template Parameters
Sthe signature of the node
NTnode type
Fittrue: fit, false: predict
Eused for node type specialization

Definition at line 75 of file operator.h.

Member Typedef Documentation

◆ ArgTypes

template<NodeType NT, typename S , bool Fit, typename E = void>
using Brush::Operator< NT, S, Fit, E >::ArgTypes
Initial value:
((UnaryOp<NT> || NaryOp<NT>) && S::ArgCount > 1),
Array<typename S::FirstArg::Scalar, -1, S::ArgCount>,
typename S::ArgTypes>
void bind_engine(py::module &m, string name)

set argument types to those of the signature unless:

a) the operator is unary and there are more than one arguments b) the operator is binary and associative

In the case of a) or b), arguments to the operator are stacked into an array and the operator is applied to that array

Definition at line 86 of file operator.h.

◆ NthType

template<NodeType NT, typename S , bool Fit, typename E = void>
template<std::size_t N>
using Brush::Operator< NT, S, Fit, E >::NthType = typename S::NthType<N>

utility for returning the type of the Nth argument

Definition at line 99 of file operator.h.

◆ RetType

template<NodeType NT, typename S , bool Fit, typename E = void>
using Brush::Operator< NT, S, Fit, E >::RetType = typename S::RetType

return type of the operator

Definition at line 92 of file operator.h.

◆ W

template<NodeType NT, typename S , bool Fit, typename E = void>
using Brush::Operator< NT, S, Fit, E >::W = typename S::WeightType

set weight type

Definition at line 102 of file operator.h.

Constructor & Destructor Documentation

◆ Operator()

template<NodeType NT, typename S , bool Fit, typename E = void>
Brush::Operator< NT, S, Fit, E >::Operator ( )
default

Member Function Documentation

◆ apply() [1/2]

template<NodeType NT, typename S , bool Fit, typename E = void>
template<typename T = ArgTypes>
requires ( is_std_array_v<T> || is_tuple_v<T>)
RetType Brush::Operator< NT, S, Fit, E >::apply ( const T & inputs) const
inline

Apply node function in a functional style.

Template Parameters
Targument types
Parameters
inputsthe child node outputs
Returns
return values applying F to the inputs

Definition at line 192 of file operator.h.

Here is the caller graph for this function:

◆ apply() [2/2]

template<NodeType NT, typename S , bool Fit, typename E = void>
template<typename T = ArgTypes>
requires ( is_eigen_array_v<T> && !is_std_array_v<T>)
RetType Brush::Operator< NT, S, Fit, E >::apply ( const T & inputs) const
inline

Apply the node function like a function.

Template Parameters
Targument types
Parameters
inputsthe child node outputs
Returns
return values applying F to the inputs

Definition at line 202 of file operator.h.

◆ eval() [1/2]

template<NodeType NT, typename S , bool Fit, typename E = void>
template<typename T = ArgTypes, typename Scalar = RetType::Scalar>
RetType Brush::Operator< NT, S, Fit, E >::eval ( const Dataset & d,
TreeNode & tn,
const W ** weights = nullptr ) const
inline

evaluate the operator on the data. main entry point.

Template Parameters
Targument types
Scalarthe underlying scalar type of the return type
Parameters
ddataset
tntree node
weightsoption pointer to a weight array, used in place of node weight
Returns
output values from applying operator function

Definition at line 215 of file operator.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eval() [2/2]

template<NodeType NT, typename S , bool Fit, typename E = void>
template<typename T = ArgTypes, typename Scalar = RetType::Scalar>
requires is_in_v<NT, NodeType::OffsetSum>
RetType Brush::Operator< NT, S, Fit, E >::eval ( const Dataset & d,
TreeNode & tn,
const W ** weights = nullptr ) const
inline

Definition at line 232 of file operator.h.

Here is the call graph for this function:

◆ get_kid()

template<NodeType NT, typename S , bool Fit, typename E = void>
template<int I>
NthType< I > Brush::Operator< NT, S, Fit, E >::get_kid ( const Dataset & d,
TreeNode & tn,
const W ** weights ) const
inline

gets one kid for a tuple of kids

Definition at line 148 of file operator.h.

Here is the call graph for this function:

◆ get_kids() [1/2]

template<NodeType NT, typename S , bool Fit, typename E = void>
template<typename T = ArgTypes>
requires (is_std_array_v<T> || is_eigen_array_v<T>)
T Brush::Operator< NT, S, Fit, E >::get_kids ( const Dataset & d,
TreeNode & tn,
const W ** weights = nullptr ) const
inline

get a std::array or eigen array of kids

Definition at line 116 of file operator.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_kids() [2/2]

template<NodeType NT, typename S , bool Fit, typename E = void>
template<typename T = ArgTypes>
requires (is_tuple_v<T>)
T Brush::Operator< NT, S, Fit, E >::get_kids ( const Dataset & d,
TreeNode & tn,
const W ** weights = nullptr ) const
inline

get a std::tuple of kids. Used when child arguments are different types.

Template Parameters
Targument types
Parameters
dthe dataset
tnthe tree node
weightsoption pointer to a weight array, used in place of node weight
Returns
a tuple of the child arguments

Definition at line 180 of file operator.h.

Here is the call graph for this function:

◆ get_kids_seq()

template<NodeType NT, typename S , bool Fit, typename E = void>
template<typename T , size_t ... Is>
requires (is_tuple_v<T>)
T Brush::Operator< NT, S, Fit, E >::get_kids_seq ( const Dataset & d,
TreeNode & tn,
const W ** weights,
std::index_sequence< Is... >  ) const
inline

Makes and returns a tuple of child outputs.

Template Parameters
Ta tuple
Isinteger sequence
Parameters
ddataset
tna tree node
Returns
a tuple with elements corresponding to each child node

Definition at line 168 of file operator.h.

Here is the call graph for this function:

Member Data Documentation

◆ ArgCount

template<NodeType NT, typename S , bool Fit, typename E = void>
constexpr size_t Brush::Operator< NT, S, Fit, E >::ArgCount = S::ArgCount
staticconstexpr

stores the argument count of the operator

Definition at line 95 of file operator.h.

◆ F

template<NodeType NT, typename S , bool Fit, typename E = void>
constexpr auto Brush::Operator< NT, S, Fit, E >::F
staticconstexpr
Initial value:
= [](const auto& ...args) {
return f(args...);
}

wrapper function for the node function

Definition at line 105 of file operator.h.


The documentation for this struct was generated from the following file: