|
ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
|
Abstract base class for predictive models (trees and forests). More...
#include <Model.hpp>
Classes | |
| class | Visitor |
| Visitor interface for model dispatch. More... | |
Public Types | |
| using | Ptr = std::shared_ptr<Model> |
Public Member Functions | |
| virtual | ~Model ()=default |
| virtual void | accept (Visitor &visitor) const =0 |
| Accept a model visitor (double dispatch). | |
| virtual types::OutcomeVector | predict (types::FeatureMatrix const &x) const |
| Predict a matrix of observations. | |
| virtual types::Outcome | predict (types::FeatureVector const &x) const =0 |
| Predict a single observation. | |
Static Public Member Functions | |
| 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. | |
Public Attributes | |
| bool | degenerate = false |
| Whether the model contains degenerate nodes/splits. | |
| TrainingSpec::Ptr | training_spec |
| Training specification used to build this model. | |
Abstract base class for predictive models (trees and forests).
| using ppforest2::Model::Ptr = std::shared_ptr<Model> |
|
virtualdefault |
|
pure virtual |
Accept a model visitor (double dispatch).
Implemented in ppforest2::ClassificationForest, ppforest2::ClassificationTree, ppforest2::Forest, ppforest2::RegressionForest, ppforest2::RegressionTree, and ppforest2::Tree.
|
static |
Validate common training inputs (y non-empty, matching x rows).
Throws UserError on failure. Called by Tree::train and Forest::train at their entry points so both modes get the same validation and the checks aren't duplicated per-mode.
|
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 in ppforest2::Forest, ppforest2::RegressionForest, and ppforest2::Tree.
|
pure virtual |
Predict a single observation.
| x | Feature vector (p). |
Implemented in ppforest2::ClassificationForest, ppforest2::ClassificationTree, ppforest2::Forest, ppforest2::RegressionForest, ppforest2::RegressionTree, and ppforest2::Tree.
|
static |
Train a model from a training specification.
Dispatches to Tree::train or Forest::train based on spec.is_forest().
| spec | Training specification. |
| x | Feature matrix (n × p). |
| y | Outcome vector (n). |
| bool ppforest2::Model::degenerate = false |
Whether the model contains degenerate nodes/splits.
| TrainingSpec::Ptr ppforest2::Model::training_spec |
Training specification used to build this model.