A projection pursuit random forest.
More...
#include <Forest.hpp>
A projection pursuit random forest.
An ensemble of BootstrapTree instances, each trained on a bootstrap sample. Predictions are made by majority vote. Out-of-bag estimation and vote-proportion predictions are supported.
DRStrategy::Ptr uniform(int n_vars)
Factory function for a uniform DR strategy.
PPStrategy::Ptr pda(float lambda)
Factory function for a PDA projection pursuit strategy.
SRStrategy::Ptr mean_of_means()
Factory function for a mean-of-means split strategy.
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
static Forest train(TrainingSpec const &training_spec, types::FeatureMatrix const &x, types::ResponseVector const &y)
Train a random forest.
double oob_error(types::FeatureMatrix const &x, types::ResponseVector const &y) const
Out-of-bag error rate.
types::Response predict(types::FeatureVector const &data) const override
Predict a single observation.
Tag type for requesting vote-proportion predictions.
Definition Model.hpp:19
Training configuration for projection pursuit trees and forests.
Definition TrainingSpec.hpp:40
◆ Forest() [1/2]
| ppforest2::Forest::Forest |
( |
| ) |
|
◆ Forest() [2/2]
◆ accept()
◆ add_tree()
| void ppforest2::Forest::add_tree |
( |
std::unique_ptr< BootstrapTree > | tree | ) |
|
Add a tree to the forest.
- Parameters
-
| tree | Tree to add (ownership transferred). |
◆ oob_error()
Out-of-bag error rate.
For each observation, predicts using majority vote of only the trees where it was out-of-bag, then computes the overall misclassification rate.
- Parameters
-
| x | Training feature matrix (n × p). |
| y | Training response vector (n). |
- Returns
- Error rate in [0, 1], or −1 if no observation has any OOB tree.
◆ oob_predict()
Out-of-bag predictions by majority vote.
For each observation, predicts using majority vote of only the trees where it was out-of-bag. Observations with no OOB tree receive a sentinel value (−1) and are excluded when computing oob_error().
- Parameters
-
| x | Training feature matrix (n × p). |
- Returns
- OOB predictions (n); −1 where no OOB tree exists.
◆ operator!=()
| bool ppforest2::Forest::operator!= |
( |
Forest const & | other | ) |
const |
◆ operator==()
| bool ppforest2::Forest::operator== |
( |
Forest const & | other | ) |
const |
◆ predict() [1/3]
Predict a matrix of observations.
- Parameters
-
| data | Feature matrix (n × p). |
- Returns
- Predictions (n).
Implements ppforest2::Model.
◆ predict() [2/3]
Predict vote proportions for a matrix of observations.
For each observation, counts votes from every tree and returns the proportion of trees that voted for each group. The number of groups G is derived from the root node of the first tree.
- Parameters
-
| data | Feature matrix (n × p). |
- Returns
- Vote proportions matrix (n × G), rows sum to 1.0.
Implements ppforest2::Model.
◆ predict() [3/3]
Predict a single observation.
- Parameters
-
- Returns
- Prediction.
Implements ppforest2::Model.
◆ train()
Train a random forest.
Forest-level parameters (size, seed, threads, max_retries) are read from the training specification.
- Parameters
-
| training_spec | Training specification. |
| x | Feature matrix (n × p). |
| y | Response vector (n). |
- Returns
- Trained forest.
◆ trees
The documentation for this struct was generated from the following file: