|
ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
|
Random forest of regression trees. More...
#include <RegressionForest.hpp>
Public Types | |
| using | FeatureMatrix = types::FeatureMatrix |
| using | FeatureVector = types::FeatureVector |
| using | Outcome = types::Outcome |
| using | OutcomeVector = types::OutcomeVector |
| using | Ptr = std::unique_ptr<RegressionForest> |
Public Types inherited from ppforest2::Forest | |
| using | FeatureMatrix = types::FeatureMatrix |
| using | FeatureVector = types::FeatureVector |
| using | Outcome = types::Outcome |
| using | OutcomeVector = types::OutcomeVector |
| using | Ptr = std::unique_ptr<Forest> |
| using | RNG = stats::RNG |
Public Types inherited from ppforest2::Model | |
| using | Ptr = std::shared_ptr<Model> |
Public Member Functions | |
| RegressionForest () | |
| RegressionForest (TrainingSpec::Ptr spec) | |
| void | accept (Model::Visitor &visitor) const override |
| Accept a model visitor (mode-specific dispatch). | |
| types::Outcome | predict (FeatureVector const &x) const override |
| Per-row prediction (mode-specific: majority vote or mean). | |
| virtual types::OutcomeVector | predict (types::FeatureMatrix const &x) const |
| Predict a matrix of observations. | |
Public Member Functions inherited from ppforest2::Forest | |
| void | add_tree (BaggedTree::Ptr tree) |
| Add a trained bagged tree to the forest. | |
| bool | operator!= (Forest const &other) const |
| bool | operator== (Forest const &other) const |
Public Member Functions inherited from ppforest2::Model | |
| virtual | ~Model ()=default |
Static Public Member Functions | |
| static Ptr | train (TrainingSpec const &spec, FeatureMatrix const &x, OutcomeVector const &y) |
Static Public Member Functions inherited from ppforest2::Forest | |
| static Ptr | train (TrainingSpec const &spec, FeatureMatrix const &x, OutcomeVector const &y) |
| Train a random forest. | |
Static Public Member Functions inherited from ppforest2::Model | |
| static void | check_train_inputs (types::FeatureMatrix const &x, types::OutcomeVector const &y) |
| Validate common training inputs (y non-empty, matching x rows). | |
| static Ptr | train (TrainingSpec const &spec, types::FeatureMatrix &x, types::OutcomeVector &y) |
| Train a model from a training specification. | |
Protected Member Functions | |
| BaggedTree::Ptr | train_tree (FeatureMatrix const &x, OutcomeVector const &y, stats::RNG &rng) const override |
Train one bagged tree on a bootstrap resample of x / y. | |
Protected Member Functions inherited from ppforest2::Forest | |
| Forest ()=default | |
| Forest (TrainingSpec::Ptr spec) | |
| void | build_trees (types::FeatureMatrix const &x, types::OutcomeVector const &y) |
Build training_spec->size bagged trees in parallel and attach them to this forest. | |
Additional Inherited Members | |
Public Attributes inherited from ppforest2::Forest | |
| std::vector< BaggedTree::Ptr > | trees |
Bootstrap-aggregated trees. Each BaggedTree pairs the polymorphic inner Tree with its sample indices. | |
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. | |
Random forest of regression trees.
Aggregates per-tree predictions by arithmetic mean. Use the free functions in Metrics.hpp for OOB diagnostics and variable importance.
| using ppforest2::RegressionForest::Ptr = std::unique_ptr<RegressionForest> |
| ppforest2::RegressionForest::RegressionForest | ( | ) |
|
explicit |
|
overridevirtual |
Accept a model visitor (mode-specific dispatch).
Implements ppforest2::Forest.
|
overridevirtual |
Per-row prediction (mode-specific: majority vote or mean).
Implements ppforest2::Forest.
|
inlinevirtual |
Predict a matrix of observations.
Default implementation iterates rows and dispatches to the single-row predict. Subclasses may override to vectorize.
| x | Feature matrix (n × p). |
Reimplemented from ppforest2::Forest.
|
static |
|
overrideprotectedvirtual |
Train one bagged tree on a bootstrap resample of x / y.
Mode-specific hook invoked by build_trees once per slot in the forest (with retries on degenerate trees). Subclasses that need per-training shared state (e.g. ClassificationForest caches the parent's label partition for stratified sampling) hold it as a private transient pointer set up before build_trees runs.
Called from inside build_trees's OpenMP parallel for, so implementations must be thread-safe and read-only over *this.
Implements ppforest2::Forest.