ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
Loading...
Searching...
No Matches
RegressionTree.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "models/Tree.hpp"
4
5namespace ppforest2 {
15 class RegressionTree : public Tree {
16 public:
17 using Ptr = std::unique_ptr<RegressionTree>;
18 using Tree::predict;
19
24 using RNG = stats::RNG;
25
27
29 : Tree(std::move(root), std::move(spec)) {
30 invariant(this->training_spec != nullptr, "RegressionTree requires a non-null TrainingSpec");
31 invariant(is_regression(this), "RegressionTree requires a regression TrainingSpec");
32 }
33
57 static Ptr train(TrainingSpec const& s, FeatureMatrix& x, OutcomeVector& y, GroupPartition const& y_part, RNG& rng);
58
59 void accept(Model::Visitor& visitor) const override;
60 };
61}
void invariant(bool condition, char const *message)
Runtime assertion that throws on failure.
Visitor interface for model dispatch.
Definition Model.hpp:51
TrainingSpec::Ptr training_spec
Training specification used to build this model.
Definition Model.hpp:70
static Ptr train(TrainingSpec const &s, FeatureMatrix &x, OutcomeVector &y, GroupPartition const &y_part, RNG &rng)
Train a regression tree with an external RNG.
void accept(Model::Visitor &visitor) const override
Accept a model visitor (mode-specific dispatch).
std::unique_ptr< RegressionTree > Ptr
Definition RegressionTree.hpp:17
stats::RNG RNG
Definition RegressionTree.hpp:24
types::FeatureMatrix FeatureMatrix
Definition RegressionTree.hpp:20
RegressionTree(TreeNode::Ptr root, TrainingSpec::Ptr spec)
Definition RegressionTree.hpp:28
types::OutcomeVector OutcomeVector
Definition RegressionTree.hpp:22
types::FeatureVector FeatureVector
Definition RegressionTree.hpp:21
stats::GroupPartition GroupPartition
Definition RegressionTree.hpp:26
types::Outcome Outcome
Definition RegressionTree.hpp:23
Training configuration for projection pursuit trees and forests.
Definition TrainingSpec.hpp:43
std::shared_ptr< TrainingSpec > Ptr
Definition TrainingSpec.hpp:45
std::unique_ptr< TreeNode > Ptr
Definition TreeNode.hpp:21
Root root
Root node of the tree.
Definition Tree.hpp:45
Tree(TreeNode::Ptr root, TrainingSpec::Ptr spec)
Definition Tree.hpp:93
types::Outcome predict(types::FeatureVector const &x) const override
Predict a single observation.
Contiguous-block representation of grouped observations.
Definition GroupPartition.hpp:40
pcg32 RNG
Definition Stats.hpp:24
Eigen::Matrix< Feature, Eigen::Dynamic, Eigen::Dynamic > FeatureMatrix
Dynamic-size matrix of feature values.
Definition Types.hpp:33
Eigen::Matrix< Outcome, Eigen::Dynamic, 1 > OutcomeVector
Dynamic-size column vector of predictions.
Definition Types.hpp:42
Eigen::Matrix< Feature, Eigen::Dynamic, 1 > FeatureVector
Dynamic-size column vector of feature values.
Definition Types.hpp:36
Feature Outcome
Scalar type for predictions (float for both classification and regression).
Definition Types.hpp:30
Binarization strategies for multiclass-to-binary reduction.
Definition Benchmark.hpp:25
bool is_regression(Model const &model)
Whether model was trained for regression.
Definition Model.hpp:155