|
ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
|
A projection pursuit decision tree for regression. More...
#include <RegressionTree.hpp>
Public Types | |
| using | FeatureMatrix = types::FeatureMatrix |
| using | FeatureVector = types::FeatureVector |
| using | GroupPartition = stats::GroupPartition |
| using | Outcome = types::Outcome |
| using | OutcomeVector = types::OutcomeVector |
| using | Ptr = std::unique_ptr<RegressionTree> |
| using | RNG = stats::RNG |
Public Types inherited from ppforest2::Tree | |
| using | FeatureMatrix = types::FeatureMatrix |
| using | FeatureVector = types::FeatureVector |
| using | GroupPartition = stats::GroupPartition |
| using | Outcome = types::Outcome |
| using | OutcomeVector = types::OutcomeVector |
| using | Ptr = std::unique_ptr<Tree> |
| using | RNG = stats::RNG |
| using | Root = TreeNode::Ptr |
Public Types inherited from ppforest2::Model | |
| using | Ptr = std::shared_ptr<Model> |
Public Member Functions | |
| RegressionTree (TreeNode::Ptr root, TrainingSpec::Ptr spec) | |
| void | accept (Model::Visitor &visitor) const override |
| Accept a model visitor (mode-specific dispatch). | |
| types::Outcome | predict (types::FeatureVector const &x) const override |
| Predict a single observation. | |
Public Member Functions inherited from ppforest2::Tree | |
| bool | operator!= (Tree const &other) const |
| bool | operator== (Tree const &other) const |
| virtual types::OutcomeVector | predict (types::FeatureMatrix const &x) const |
| Predict a matrix of observations. | |
| types::Outcome | predict (types::FeatureVector const &x) const override |
| Predict a single observation. | |
Public Member Functions inherited from ppforest2::Model | |
| virtual | ~Model ()=default |
Static Public Member Functions | |
| static Ptr | train (TrainingSpec const &s, FeatureMatrix &x, OutcomeVector &y, GroupPartition const &y_part, RNG &rng) |
| Train a regression tree with an external RNG. | |
Static Public Member Functions inherited from ppforest2::Tree | |
| static Ptr | train (TrainingSpec const &spec, types::FeatureMatrix &x, types::OutcomeVector &y) |
| Train a tree from a response vector. | |
| static Ptr | train (TrainingSpec const &spec, types::FeatureMatrix &x, types::OutcomeVector &y, stats::RNG &rng) |
| Train a tree from a response vector. | |
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. | |
Additional Inherited Members | |
Public Attributes inherited from ppforest2::Tree | |
| Root | 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. | |
Protected Member Functions inherited from ppforest2::Tree | |
| Tree (TreeNode::Ptr root, TrainingSpec::Ptr spec) | |
Static Protected Member Functions inherited from ppforest2::Tree | |
| static Root | build_root (TrainingSpec const &spec, FeatureMatrix &x, OutcomeVector &y, GroupPartition const &y_part, RNG &rng) |
| Build the root node of a tree. | |
A projection pursuit decision tree for regression.
Leaves hold continuous mean response values produced by the MeanResponse leaf strategy. Training requires a y vector; in-place reordering of feature rows happens inside the build loop via the ByCutpoint grouping strategy.
| using ppforest2::RegressionTree::Ptr = std::unique_ptr<RegressionTree> |
|
inline |
|
overridevirtual |
Accept a model visitor (mode-specific dispatch).
Implements ppforest2::Tree.
|
overridevirtual |
Predict a single observation.
Walks the tree and returns the leaf value. Same implementation for both modes — the leaf value is produced by the mode-specific leaf strategy during training.
Implements ppforest2::Model.
|
static |
Train a regression tree with an external RNG.
Takes x and y by non-const reference. The ByCutpoint grouping strategy reorders rows in place on the caller's storage — there is no internal copy. Callers must pass buffers they own and are willing to see mutated. Typical callers:
Tree::train path: the top-level dispatcher holds the caller's data as const&, so it makes a single copy of x and y at the call site before invoking this function. The copy is visible at the caller, not hidden inside.| s | Training specification (must have mode = Regression). |
| x | Feature matrix (n × p), sorted by continuous response. Will be permuted in place during training. |
| y | Continuous response vector (n), same order as x. Will be permuted in place during training. |
| y_part | Initial root group partition (typically a median split). |
| rng | Random number generator. |