|
ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
|
#include <BootstrapTree.hpp>
Public Types | |
| using | Ptr = std::unique_ptr<BootstrapTree> |
Public Types inherited from ppforest2::Model | |
| using | Ptr = std::shared_ptr<Model> |
Public Member Functions | |
| BootstrapTree (TreeNode::Ptr root, TrainingSpec::Ptr spec, std::vector< int > samp) | |
| std::vector< int > | oob_indices (int n_total) const |
| Indices of observations not in the bootstrap sample. | |
| 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). | |
| Tree (TreeNode::Ptr root, TrainingSpec::Ptr training_spec) | |
Public Member Functions inherited from ppforest2::Tree | |
| Tree (TreeNode::Ptr root, TrainingSpec::Ptr training_spec) | |
| void | accept (Model::Visitor &visitor) const override |
| Accept a model visitor (double dispatch). | |
| bool | operator!= (Tree const &other) const |
| bool | operator== (Tree const &other) const |
| types::ResponseVector | predict (types::FeatureMatrix const &data) const override |
| Predict a matrix of observations. | |
| types::FeatureMatrix | predict (types::FeatureMatrix const &data, Proportions) const override |
| Predict proportions for a matrix of observations. | |
| types::Response | predict (types::FeatureVector const &data) const override |
| Predict a single observation. | |
Public Member Functions inherited from ppforest2::Model | |
| virtual | ~Model ()=default |
Static Public Member Functions | |
| static Ptr | train (TrainingSpec::Ptr const &training_spec, types::FeatureMatrix const &x, stats::GroupPartition const &group_spec, stats::RNG &rng) |
| Train a bootstrap tree. | |
Static Public Member Functions inherited from ppforest2::Tree | |
| static Tree | train (TrainingSpec const &training_spec, types::FeatureMatrix const &x, stats::GroupPartition const &group_spec, stats::RNG &rng) |
| Train a tree from a group partition. | |
| static Tree | train (TrainingSpec const &training_spec, types::FeatureMatrix const &x, types::ResponseVector const &y, stats::RNG &rng) |
| Train a tree from a response vector. | |
Static Public Member Functions inherited from ppforest2::Model | |
| static Ptr | train (TrainingSpec const &spec, types::FeatureMatrix const &x, types::ResponseVector const &y) |
| Train a model from a training specification. | |
Public Attributes | |
| std::vector< int > | sample_indices |
Public Attributes inherited from ppforest2::Tree | |
| TreeNode::Ptr | root |
| Root node of the tree. | |
Public Attributes inherited from ppforest2::Model | |
| bool | degenerate = false |
| Whether the model contains degenerate nodes/splits. | |
| TrainingSpec::Ptr | training_spec |
| Training specification used to build this model. | |
| using ppforest2::BootstrapTree::Ptr = std::unique_ptr<BootstrapTree> |
| ppforest2::BootstrapTree::BootstrapTree | ( | TreeNode::Ptr | root, |
| TrainingSpec::Ptr | spec, | ||
| std::vector< int > | samp ) |
| std::vector< int > ppforest2::BootstrapTree::oob_indices | ( | int | n_total | ) | const |
Indices of observations not in the bootstrap sample.
| n_total | Total number of observations in the training set. |
| types::ResponseVector ppforest2::BootstrapTree::predict_oob | ( | types::FeatureMatrix const & | x, |
| std::vector< int > const & | row_idx ) const |
Predict for a subset of rows (e.g. OOB indices).
Typically used with oob_indices() to obtain predictions for out-of-bag observations only. The returned vector has the same size as row_idx; element i is the prediction for row row_idx[i].
| x | Feature matrix (n × p). |
| row_idx | Row indices to predict. |
|
static |
Train a bootstrap tree.
Samples rows from x according to group_spec, trains a tree on the sampled data, and stores the sample indices for OOB queries.
| training_spec | Training specification (shared). |
| x | Feature matrix (n × p). |
| group_spec | Group partition for stratified sampling. |
| rng | Random number generator. |
| ppforest2::Tree::Tree | ( | TreeNode::Ptr | root, |
| TrainingSpec::Ptr | training_spec ) |
| std::vector<int> ppforest2::BootstrapTree::sample_indices |