ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
Loading...
Searching...
No Matches
BootstrapTree.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "utils/Types.hpp"
4#include "models/Tree.hpp"
5
6#include <vector>
7
8namespace ppforest2 {
9 struct BootstrapTree : public Tree {
10 using Tree::Tree;
11 using Ptr = std::unique_ptr<BootstrapTree>;
12
26 types::FeatureMatrix const& x,
27 stats::GroupPartition const& group_spec,
28 stats::RNG& rng);
29
30 std::vector<int> sample_indices;
31
32 BootstrapTree(TreeNode::Ptr root, TrainingSpec::Ptr spec, std::vector<int> samp);
33
40 std::vector<int> oob_indices(int n_total) const;
41
54 types::ResponseVector predict_oob(types::FeatureMatrix const& x, std::vector<int> const& row_idx) const;
55 };
56}
Contiguous-block representation of grouped observations.
Definition GroupPartition.hpp:42
pcg32 RNG
Definition Stats.hpp:19
Eigen::Matrix< Feature, Eigen::Dynamic, Eigen::Dynamic > FeatureMatrix
Dynamic-size matrix of feature values.
Definition Types.hpp:24
Eigen::Matrix< Response, Eigen::Dynamic, 1 > ResponseVector
Dynamic-size column vector of group labels.
Definition Types.hpp:29
Definition Benchmark.hpp:22
BootstrapTree(TreeNode::Ptr root, TrainingSpec::Ptr spec, std::vector< int > samp)
types::ResponseVector predict_oob(types::FeatureMatrix const &x, std::vector< int > const &row_idx) const
Predict for a subset of rows (e.g. OOB indices).
static Ptr train(TrainingSpec::Ptr const &training_spec, types::FeatureMatrix const &x, stats::GroupPartition const &group_spec, stats::RNG &rng)
Train a bootstrap tree.
Tree(TreeNode::Ptr root, TrainingSpec::Ptr training_spec)
std::unique_ptr< BootstrapTree > Ptr
Definition BootstrapTree.hpp:11
std::vector< int > oob_indices(int n_total) const
Indices of observations not in the bootstrap sample.
std::vector< int > sample_indices
Definition BootstrapTree.hpp:30
TrainingSpec::Ptr training_spec
Training specification used to build this model.
Definition Model.hpp:45
std::shared_ptr< TrainingSpec > Ptr
Definition TrainingSpec.hpp:41
std::unique_ptr< TreeNode > Ptr
Definition TreeNode.hpp:20
TreeNode::Ptr root
Root node of the tree.
Definition Tree.hpp:62
Tree(TreeNode::Ptr root, TrainingSpec::Ptr training_spec)