|
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 | |
| struct | 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::ResponseVector | predict (types::FeatureMatrix const &data) const =0 |
| Predict a matrix of observations. | |
| virtual types::FeatureMatrix | predict (types::FeatureMatrix const &data, Proportions) const =0 |
| Predict proportions for a matrix of observations. | |
| virtual types::Response | predict (types::FeatureVector const &data) const =0 |
| Predict a single observation. | |
Static Public Member Functions | |
| static Ptr | train (TrainingSpec const &spec, types::FeatureMatrix const &x, types::ResponseVector const &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::Forest, and ppforest2::Tree.
|
pure virtual |
Predict a matrix of observations.
| data | Feature matrix (n × p). |
Implemented in ppforest2::Forest, and ppforest2::Tree.
|
pure virtual |
Predict proportions for a matrix of observations.
Returns an (n × G) matrix. For forests, each row contains the fraction of trees that voted for each group. For single trees, each row is a one-hot encoding of the predicted group.
| data | Feature matrix (n × p). |
Implemented in ppforest2::Forest, and ppforest2::Tree.
|
pure virtual |
Predict a single observation.
| data | Feature vector (p). |
Implemented in ppforest2::Forest, 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 | Response 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.