StochTree 0.5.0.9000
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions | Variables
StochTree Namespace Reference

A collection of random number generation utilities. More...

Classes

struct  BARTConfig
 
struct  BARTData
 
struct  BARTPredictionMetadata
 Metadata for the BART prediction routine. More...
 
struct  BARTPredictionResult
 Struct returning BART model predictions. More...
 
struct  BARTPredTerms
 Selector for model terms that should be predicted. More...
 
class  BARTSampler
 
struct  BARTSamples
 
struct  BCFConfig
 
struct  BCFData
 
struct  BCFPredictionMetadata
 Metadata for the BCF prediction routine. More...
 
struct  BCFPredictionResult
 Struct returning BCF model predictions. More...
 
struct  BCFPredTerms
 Selector for model terms that should be predicted. More...
 
class  BCFSampler
 
struct  BCFSamples
 
class  CategorySampleTracker
 Mapping categories to the indices they contain TODO: Add run-time checks for categories with a few observations.
 
class  CloglogOrdinalLeafModel
 Marginal likelihood and posterior computation for complementary log-log ordinal BART model. More...
 
class  CloglogOrdinalSuffStat
 Sufficient statistic and associated operations for complementary log-log ordinal BART model. More...
 
class  ColumnMatrix
 Internal wrapper around Eigen::MatrixXd interface for multidimensional floating point data. More...
 
class  ColumnVector
 Internal wrapper around Eigen::VectorXd interface for univariate floating point data. The (frequently updated) full / partial residual used in sampling forests is stored internally as a ColumnVector by the sampling functions (see Forest Sampler API). More...
 
class  CutpointGridContainer
 Container class for FeatureCutpointGrid objects stored for every feature in a dataset. More...
 
class  FeatureCutpointGrid
 Computing and tracking cutpoints available for a given feature at a given node Store cutpoint bins in 0-indexed fashion, so that if a given node has. More...
 
class  FeaturePresortPartition
 Data structure that tracks pre-sorted feature values through a tree's split lifecycle. More...
 
class  FeaturePresortRoot
 Data structure for presorting a feature by its values. More...
 
class  FeaturePresortRootContainer
 Container class for FeaturePresortRoot objects stored for every feature in a dataset. More...
 
class  FeatureUnsortedPartition
 Mapping nodes to the indices they contain. More...
 
class  ForestContainer
 Container of TreeEnsemble forest objects. This is the primary (in-memory) storage interface for multiple "samples" of a decision tree ensemble in stochtree. More...
 
class  ForestDataset
 API for loading and accessing data used to sample tree ensembles The covariates / bases / weights used in sampling forests are stored internally as a ForestDataset by the sampling functions (see Forest Sampler API). More...
 
class  ForestTracker
 "Superclass" wrapper around tracking data structures for forest sampling algorithms More...
 
class  gamma_sampler
 
class  GammaSampler
 
class  GaussianConstantLeafModel
 Marginal likelihood and posterior computation for gaussian homoskedastic constant leaf outcome model. More...
 
class  GaussianConstantSuffStat
 Sufficient statistic and associated operations for gaussian homoskedastic constant leaf outcome model. More...
 
class  GaussianMultivariateRegressionLeafModel
 Marginal likelihood and posterior computation for gaussian homoskedastic constant leaf outcome model. More...
 
class  GaussianMultivariateRegressionSuffStat
 Sufficient statistic and associated operations for gaussian homoskedastic constant leaf outcome model. More...
 
class  GaussianUnivariateRegressionLeafModel
 Marginal likelihood and posterior computation for gaussian homoskedastic constant leaf outcome model. More...
 
class  GaussianUnivariateRegressionSuffStat
 Sufficient statistic and associated operations for gaussian homoskedastic constant leaf outcome model. More...
 
class  GlobalHomoskedasticVarianceModel
 Marginal likelihood and posterior computation for gaussian homoskedastic constant leaf outcome model. More...
 
class  IGVariancePrior
 
class  InverseGammaSampler
 
class  LabelMapper
 Standalone container for the map from category IDs to 0-based indices. More...
 
class  LeafNodeHomoskedasticVarianceModel
 Marginal likelihood and posterior computation for gaussian homoskedastic constant leaf outcome model. More...
 
class  LogLinearVarianceLeafModel
 Marginal likelihood and posterior computation for heteroskedastic log-linear variance model. More...
 
class  LogLinearVarianceSuffStat
 Sufficient statistic and associated operations for heteroskedastic log-linear variance model. More...
 
class  MultivariateNormalSampler
 
class  MultivariateRegressionRandomEffectsModel
 Posterior computation and sampling and state storage for random effects model with a group-level multivariate basis regression. More...
 
class  NodeCutpointTracker
 Computing and tracking cutpoints available for a given feature at a given node. More...
 
class  NodeOffsetSize
 Tracking cutpoints available at a given node. More...
 
class  OrdinalSampler
 Sampler for ordinal model hyperparameters. More...
 
class  RandomEffectsContainer
 
class  RandomEffectsDataset
 API for loading and accessing data used to sample (additive) random effects. More...
 
class  RandomEffectsGaussianPrior
 
class  RandomEffectsRegressionGaussianPrior
 
class  RandomEffectsTracker
 Wrapper around data structures for random effects sampling algorithms. More...
 
class  SampleCategoryMapper
 Class storing sample-node map for each tree in an ensemble TODO: Add run-time checks for categories with a few observations. More...
 
class  SampleNodeMapper
 Class storing sample-node map for each tree in an ensemble. More...
 
class  SamplePredMapper
 Class storing sample-prediction map for each tree in an ensemble. More...
 
class  SortedNodeSampleTracker
 Data structure for tracking observations through a tree partition with each feature pre-sorted. More...
 
class  standard_normal
 
class  Tree
 Decision tree data structure. More...
 
class  TreeEnsemble
 Class storing a "forest," or an ensemble of decision trees. More...
 
class  TreePrior
 
class  TreeSplit
 Representation of arbitrary tree split rules, including numeric split rules (X[,i] <= c) and categorical split rules (X[,i] in {2,4,6,7}) More...
 
class  UnivariateNormalSampler
 
class  UnsortedNodeSampleTracker
 Mapping nodes to the indices they contain. More...
 
class  walker_vose
 

Typedefs

using SuffStatVariant = std::variant< GaussianConstantSuffStat, GaussianUnivariateRegressionSuffStat, GaussianMultivariateRegressionSuffStat, LogLinearVarianceSuffStat, CloglogOrdinalSuffStat >
 Unifying layer for disparate sufficient statistic class types.
 
using LeafModelVariant = std::variant< GaussianConstantLeafModel, GaussianUnivariateRegressionLeafModel, GaussianMultivariateRegressionLeafModel, LogLinearVarianceLeafModel, CloglogOrdinalLeafModel >
 Unifying layer for disparate leaf model class types.
 

Enumerations

enum  ModelType
 Leaf models for the forest sampler: More...
 
enum class  PredType
 Determines whether posterior predictions are returned as-is or pre-aggregated.
 
enum class  PredScale
 Determines the scale of predictions (i.e. whether a probability / class transformation is applied) More...
 
enum  TreeNodeType
 Tree node type.
 

Functions

void AppendForestContainerSamples (std::unique_ptr< ForestContainer > &dst, const std::unique_ptr< ForestContainer > &src, const char *name)
 Append every retained forest sample from src onto the end of dst (deep copy). Used by BARTSamples::Merge / BCFSamples::Merge to combine independently-sampled chains. The forest must be present in both samples objects or neither; name labels the forest in the mismatch error.
 
static void ExtractMultipleFeaturesFromMemory (std::vector< std::string > *text_data, const Parser *parser, std::vector< int > &column_indices, Eigen::MatrixXd &data, data_size_t num_rows)
 Extract multiple features from the raw data loaded from a file into an Eigen::MatrixXd. Lightly modified from LightGBM's datasetloader interface to support stochtree's use cases.
 
static void ExtractSingleFeatureFromMemory (std::vector< std::string > *text_data, const Parser *parser, int column_index, Eigen::VectorXd &data, data_size_t num_rows)
 Extract a single feature from the raw data loaded from a file into an Eigen::VectorXd. Lightly modified from LightGBM's datasetloader interface to support stochtree's use cases.
 
template<typename container_type , typename prob_type >
void sample_without_replacement (container_type *output, prob_type *p, container_type *a, int population_size, int sample_size, std::mt19937 &gen)
 Sample without replacement according to a set of probability weights. This template function is a C++ variant of numpy's implementation: https://github.com/numpy/numpy/blob/031f44252d613f4524ad181e3eb2ae2791e22187/numpy/random/_generator.pyx#L925.
 
double norm_cdf (double x)
 
double norm_inv_cdf (double p)
 
double standard_uniform_draw_53bit (std::mt19937 &gen)
 
double standard_uniform_draw_32bit (std::mt19937 &gen)
 
double sample_standard_normal (double mean, double sd, std::mt19937 &gen)
 
double sample_gamma (std::mt19937 &gen, double shape, double scale)
 
double sample_std_truncnorm_upper (std::mt19937 &gen)
 
double sample_std_truncnorm_lower (std::mt19937 &gen)
 
static SuffStatVariant suffStatFactory (ModelType model_type, int basis_dim=0)
 Factory function that creates a new SuffStat object for the specified model type.
 
static LeafModelVariant leafModelFactory (ModelType model_type, double tau, Eigen::MatrixXd &Sigma0, double a, double b)
 Factory function that creates a new LeafModel object for the specified model type.
 
static double sample_univariate_gaussian_regression_coefficient (double *y, double *x, double error_variance, double prior_variance, int n, std::mt19937 &gen)
 Sample a regression coefficient from the posterior distribution of a univariate Gaussian regression model with known error variance and known prior variance.
 
static void sample_general_bivariate_gaussian_regression_coefficients (double *output, double *y, double *x1, double *x2, double error_variance, double prior_variance_11, double prior_variance_12, double prior_variance_22, int n, std::mt19937 &gen)
 Sample regression coefficients from the posterior distribution of a bivariate Gaussian regression model with known error variance and known prior variance.
 
static void sample_diagonal_bivariate_gaussian_regression_coefficients (double *output, double *y, double *x1, double *x2, double error_variance, double prior_variance_11, double prior_variance_22, int n, std::mt19937 &gen)
 Sample regression coefficients from the posterior distribution of a bivariate Gaussian regression model with known error variance and known diagonal prior variance.
 
static Eigen::VectorXd sample_general_gaussian_regression_coefficients (const Eigen::Ref< const Eigen::VectorXd > &y, const Eigen::Ref< const Eigen::MatrixXd > &X, double error_variance, const Eigen::Ref< const Eigen::MatrixXd > &prior_variance, int n, std::mt19937 &gen)
 Sample regression coefficients from the posterior distribution of a bivariate Gaussian regression model with known error variance and known diagonal prior variance.
 
BARTPredictionResult predict_bart_model (BARTData &data, BARTSamples &samples, BARTPredictionMetadata &metadata)
 BART prediction function.
 
BCFPredictionResult predict_bcf_model (BCFData &data, BCFSamples &samples, BCFPredictionMetadata &metadata)
 BCF prediction function.
 
void AppendRandomEffectsContainerSamples (std::unique_ptr< RandomEffectsContainer > &dst, const std::unique_ptr< RandomEffectsContainer > &src)
 Append every retained random effects sample from src onto the end of dst (deep copy). Used by BARTSamples::Merge / BCFSamples::Merge to combine independently-sampled chains. The random effects must be present in both samples objects or neither.
 
std::string TreeNodeTypeToString (TreeNodeType type)
 Get string representation of TreeNodeType.
 
TreeNodeType TreeNodeTypeFromString (std::string const &name)
 Get NodeType from string.
 
bool operator== (const Tree &lhs, const Tree &rhs)
 Comparison operator for trees.
 
bool SplitTrueNumeric (double fvalue, double threshold)
 Determine whether an observation produces a "true" value in a numeric split node.
 
bool SplitTrueCategorical (double fvalue, std::vector< std::uint32_t > const &category_list)
 Determine whether an observation produces a "true" value in a categorical split node.
 
int NextNodeNumeric (double fvalue, double threshold, int left_child, int right_child)
 Return left or right node id based on a numeric split.
 
int NextNodeCategorical (double fvalue, std::vector< std::uint32_t > const &category_list, int left_child, int right_child)
 Return left or right node id based on a categorical split.
 
int EvaluateTree (Tree const &tree, Eigen::MatrixXd &data, int row)
 
int EvaluateTree (Tree const &tree, Eigen::Map< Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > > &data, int row)
 
bool RowSplitLeft (Eigen::MatrixXd &covariates, int row, int split_index, double split_value)
 Determine whether a given observation is "true" at a split proposed by split_index and split_value.
 
bool RowSplitLeft (Eigen::MatrixXd &covariates, int row, int split_index, std::vector< std::uint32_t > const &category_list)
 Determine whether a given observation is "true" at a split proposed by split_index and split_value.
 
static void VarSplitRange (ForestTracker &tracker, ForestDataset &dataset, int tree_num, int leaf_split, int feature_split, double &var_min, double &var_max)
 Computer the range of available split values for a continuous variable, given the current structure of a tree.
 
static bool NodesNonConstantAfterSplit (ForestDataset &dataset, ForestTracker &tracker, TreeSplit &split, int tree_num, int leaf_split, int feature_split)
 Determines whether a proposed split creates two leaf nodes with constant values for every feature (thus ensuring that the tree cannot split further).
 
template<typename LeafModel , typename LeafSuffStat , typename... LeafSuffStatConstructorArgs>
static void GFRSampleOneIter (TreeEnsemble &active_forest, ForestTracker &tracker, ForestContainer &forests, LeafModel &leaf_model, ForestDataset &dataset, ColumnVector &residual, TreePrior &tree_prior, std::mt19937 &gen, std::vector< double > &variable_weights, std::vector< int > &sweep_update_indices, double global_variance, std::vector< FeatureType > &feature_types, int cutpoint_grid_size, bool keep_forest, bool pre_initialized, bool backfitting, int num_features_subsample, int num_threads, LeafSuffStatConstructorArgs &... leaf_suff_stat_args)
 
template<typename LeafModel , typename LeafSuffStat , typename... LeafSuffStatConstructorArgs>
static void MCMCSampleOneIter (TreeEnsemble &active_forest, ForestTracker &tracker, ForestContainer &forests, LeafModel &leaf_model, ForestDataset &dataset, ColumnVector &residual, TreePrior &tree_prior, std::mt19937 &gen, std::vector< double > &variable_weights, std::vector< int > &sweep_update_indices, double global_variance, bool keep_forest, bool pre_initialized, bool backfitting, int num_threads, LeafSuffStatConstructorArgs &... leaf_suff_stat_args)
 Runs one iteration of the MCMC sampler for a tree ensemble model, which consists of two steps for every tree in a forest:
 

Variables

static constexpr double Phi_0 = 0.5
 

Detailed Description

A collection of random number generation utilities.

Copyright (c) 2026 stochtree authors. All rights reserved. Licensed under the MIT License. See LICENSE file in the project root for license information.

Copyright (c) 2024 stochtree authors.

General-purpose data structures used for keeping track of categories in a training dataset.

SampleCategoryMapper is a simplified version of SampleNodeMapper, which is not tree-specific as it tracks categories loaded into a training dataset, and we do not expect to modify it during training.

SampleCategoryMapper is used in two places:

  1. Group random effects: mapping observations to group IDs for the purpose of computing random effects
  2. Heteroskedasticity based on fixed categories (as opposed to partitions as in HBART by Pratola et al 2018)
    • One example of this would be binary treatment causal inference with separate outcome variances for the treated and control groups (as in Krantsevich et al 2023)

CategorySampleTracker is a simplified version of FeatureUnsortedPartition, which as above does not vary based on tree / partition and is not expected to change during training.

SampleNodeMapper is inspired by the design of the DataPartition class in LightGBM, released under the MIT license with the following copyright:

Copyright (c) 2016 Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE file in the project root for license information.

Copyright (c) 2024 stochtree authors. All rights reserved.

Simple container-like interfaces for samples of common models.

Copyright (c) 2024 stochtree authors.

Data structures for enumerating potential cutpoint candidates.

This is used in the XBART family of algorithms, which samples split rules based on the log marginal likelihood of every potential cutpoint. For numeric variables with large sample sizes, it is often unnecessary to consider every unique value, so we allow for an adaptive "grid" of potential cutpoint values.

Algorithms for enumerating cutpoints take Dataset and SortedNodeSampleTracker objects as inputs, so that each feature is "pre-sorted" according to its value within a given node. The size of the adaptive cutpoint grid is set by the cutpoint_grid_size configuration parameter.

Numeric Features

When a node has fewer available observations than cutpoint_grid_size, full enumeration of unique available cutpoints is done via the EnumerateNumericCutpointsDeduplication function

When a node has more available observations than cutpoint_grid_size, potential cutpoints are "thinned out" by considering every k-th observation, where k is implied by the number of observations and the target cutpoint_grid_size.

Ordered Categorical Features

In this case, the grid is every unique value of the ordered categorical feature in ascending order.

Unordered Categorical Features

In this case, the grid is every unique value of the unordered categorical feature, arranged in an outcome-dependent order, as described in Fisher (1958)

Copyright (c) 2024 stochtree authors. All rights reserved. Licensed under the MIT License. See LICENSE file in the project root for license information.

This file is vendored from a broader C++ / R distribution library, where the distributions are subject to rigorous testing. https://github.com/andrewherren/cpp11_r_rng

Copyright (c) 2024 stochtree authors. All rights reserved.

Copyright (c) 2025 stochtree authors. All rights reserved. Licensed under the MIT License. See LICENSE file in the project root for license information.

Copyright (c) 2024 stochtree authors.

Data structures used for tracking dataset through the tree building process.

The first category of data structure tracks observations available in nodes of a tree. a. UnsortedNodeSampleTracker tracks the observations available in every leaf of every tree in an ensemble, in no feature-specific sort order. It is primarily designed for use in BART-based algorithms. b. SortedNodeSampleTracker tracks the observations available in a every leaf of a tree, pre-sorted separately for each feature. It is primarily designed for use in XBART-based algorithms.

The second category, SampleNodeMapper, maps observations from a dataset to leaf nodes.

SampleNodeMapper is inspired by the design of the DataPartition class in LightGBM, released under the MIT license with the following copyright:

Copyright (c) 2016 Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE file in the project root for license information.

SortedNodeSampleTracker is inspired by the "approximate" split finding method in xgboost, released under the Apache license with the following copyright:

Copyright 2015~2023 by XGBoost Contributors

Copyright (c) 2023 stochtree authors. All rights reserved. Licensed under the MIT License. See LICENSE file in the project root for license information.

Enumeration Type Documentation

◆ PredScale

Determines the scale of predictions (i.e. whether a probability / class transformation is applied)

Options are

  • linear (i.e. raw) scale,
  • probability scale,
  • class predictions.

Only valid for binary / ordinal outcome models.

Function Documentation

◆ norm_cdf()

double StochTree::norm_cdf ( double  x)
inline

Standard normal cumulative distribution function, implemented via the complementary error function.

◆ norm_inv_cdf()

double StochTree::norm_inv_cdf ( double  p)
inline

Standard normal quantile function (inverse CDF), implemented via the inverse complementary error function.

◆ standard_uniform_draw_53bit()

double StochTree::standard_uniform_draw_53bit ( std::mt19937 &  gen)
inline

Generate a standard uniform random variate to 53 bits of precision via two mersenne twisters, see: https://github.com/numpy/numpy/blob/0d7986494b39ace565afda3de68be528ddade602/numpy/random/src/mt19937/mt19937.h#L56

◆ standard_uniform_draw_32bit()

double StochTree::standard_uniform_draw_32bit ( std::mt19937 &  gen)
inline

Generate a standard uniform random variate to 32 bits of precision via a single mersenne twister.

◆ sample_standard_normal()

double StochTree::sample_standard_normal ( double  mean,
double  sd,
std::mt19937 &  gen 
)
inline

Stateless standard normal sampler implementing Marsaglia's polar method. Without caching, this is half as fast as other methods for repeated normal sampling, but this might be acceptable in cases where a relatively small number of normal draws is desired.

Reference: https://en.wikipedia.org/wiki/Marsaglia_polar_method

◆ sample_gamma()

double StochTree::sample_gamma ( std::mt19937 &  gen,
double  shape,
double  scale 
)
inline

Generate a single sample from a gamma distribution using a combination of algorithms When shape < 1.0, use the Ahrens-Dieter method When shape > 1.0, use the Marsaglia-Tsang method When shape == 1.0, sample an exponential via inverse transform method When shape == 0.0, return 0.0 https://en.wikipedia.org/wiki/Gamma_distribution#Random_variate_generation

◆ sample_std_truncnorm_upper()

double StochTree::sample_std_truncnorm_upper ( std::mt19937 &  gen)
inline

Generate a single sample from a truncated standard normal distribution, bounded above by 0.

◆ sample_std_truncnorm_lower()

double StochTree::sample_std_truncnorm_lower ( std::mt19937 &  gen)
inline

Generate a single sample from a truncated standard normal distribution, bounded below by 0.

◆ sample_univariate_gaussian_regression_coefficient()

static double StochTree::sample_univariate_gaussian_regression_coefficient ( double y,
double x,
double  error_variance,
double  prior_variance,
int  n,
std::mt19937 &  gen 
)
static

Sample a regression coefficient from the posterior distribution of a univariate Gaussian regression model with known error variance and known prior variance.

Parameters
yPointer to outcome array of length n
xPointer to covariate array of length n
error_varianceKnown error variance (sigma^2)
prior_varianceKnown prior variance (tau^2)
nNumber of observations
genRandom number generator
Returns
double

◆ sample_general_bivariate_gaussian_regression_coefficients()

static void StochTree::sample_general_bivariate_gaussian_regression_coefficients ( double output,
double y,
double x1,
double x2,
double  error_variance,
double  prior_variance_11,
double  prior_variance_12,
double  prior_variance_22,
int  n,
std::mt19937 &  gen 
)
static

Sample regression coefficients from the posterior distribution of a bivariate Gaussian regression model with known error variance and known prior variance.

Parameters
outputPointer to sampled coefficient array of length 2, where the sampled coefficients will be stored
yPointer to outcome array of length n
x1Pointer to first covariate array of length n
x2Pointer to second covariate array of length n
error_varianceKnown error variance (sigma^2)
prior_variance_11First diagonal element of the known prior covariance matrix (tau^2 for the first coefficient)
prior_variance_12Off-diagonal element of the known prior covariance matrix (covariance between the two coefficients) – note that this is the same as prior_variance_21 so only one off-diagonal element is needed
prior_variance_22Second diagonal element of the known prior covariance matrix (tau^2 for the second coefficient)
nNumber of observations
genRandom number generator

◆ sample_diagonal_bivariate_gaussian_regression_coefficients()

static void StochTree::sample_diagonal_bivariate_gaussian_regression_coefficients ( double output,
double y,
double x1,
double x2,
double  error_variance,
double  prior_variance_11,
double  prior_variance_22,
int  n,
std::mt19937 &  gen 
)
static

Sample regression coefficients from the posterior distribution of a bivariate Gaussian regression model with known error variance and known diagonal prior variance.

Parameters
outputPointer to sampled coefficient array of length 2, where the sampled coefficients will be stored
yPointer to outcome array of length n
x1Pointer to first covariate array of length n
x2Pointer to second covariate array of length n
error_varianceKnown error variance (sigma^2)
prior_variance_11First diagonal element of the known prior covariance matrix (tau^2 for the first coefficient)
prior_variance_22Second diagonal element of the known prior covariance matrix (tau^2 for the second coefficient)
nNumber of observations
genRandom number generator

◆ sample_general_gaussian_regression_coefficients()

static Eigen::VectorXd StochTree::sample_general_gaussian_regression_coefficients ( const Eigen::Ref< const Eigen::VectorXd > &  y,
const Eigen::Ref< const Eigen::MatrixXd > &  X,
double  error_variance,
const Eigen::Ref< const Eigen::MatrixXd > &  prior_variance,
int  n,
std::mt19937 &  gen 
)
static

Sample regression coefficients from the posterior distribution of a bivariate Gaussian regression model with known error variance and known diagonal prior variance.

Parameters
yEigen::VectorXd of outcomes of length n
XEigen::MatrixXd of covariates with n rows and p columns
error_varianceKnown error variance (sigma^2)
prior_varianceEigen::MatrixXd of known prior covariance matrix (tau^2 for the coefficients) of dimension p x p
nNumber of observations
genRandom number generator

◆ predict_bart_model()

BARTPredictionResult StochTree::predict_bart_model ( BARTData data,
BARTSamples samples,
BARTPredictionMetadata metadata 
)

BART prediction function.

Accepts BARTData, BARTSamples, and a struct of metadata, which dictates the model terms for which predictions are computed / returned and any transformations done before returning (i.e. pre-aggregation, probit function transformation).

Parameters
dataStruct wrapping pointers to prediction data from R / Python
samplesObject storing BART samples
metadataStruct containing prediction metadata
Returns
BARTPredictionResult struct containing prediction vectors

◆ predict_bcf_model()

BCFPredictionResult StochTree::predict_bcf_model ( BCFData data,
BCFSamples samples,
BCFPredictionMetadata metadata 
)

BCF prediction function.

Accepts BCFData, BCFSamples, and a struct of metadata, which dictates the model terms for which predictions are computed / returned and any transformations done before returning (i.e. pre-aggregation, probit function transformation).

Parameters
dataStruct wrapping pointers to prediction data from R / Python
samplesObject storing BCF samples
metadataStruct containing prediction metadata
Returns
BCFPredictionResult struct containing prediction vectors

Variable Documentation

◆ Phi_0

constexpr double StochTree::Phi_0 = 0.5
staticconstexpr

Precomputed standard normal CDF at 0