ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
Loading...
Searching...
No Matches
TreeBranch.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "models/TreeNode.hpp"
5#include "utils/Types.hpp"
6
7namespace ppforest2 {
15 class TreeBranch final : public TreeNode {
16 public:
17 using Ptr = std::unique_ptr<TreeBranch>;
18
27
29 std::set<types::GroupId> groups;
32
38 std::set<types::GroupId> groups = {},
40 );
41
42 void accept(TreeNode::Visitor& visitor) const override;
43
45 types::Outcome response() const override;
46
57
58 int group_count() const override { return static_cast<int>(groups.size()); }
59
60 std::set<types::GroupId> node_groups() const override { return groups; }
61
62 bool equals(TreeNode const& other) const override;
63 TreeNode::Ptr clone() const override;
64
66 static Ptr make(
71 std::set<types::GroupId> groups = {},
73 );
74 };
75}
types::Outcome predict(types::FeatureVector const &x) const override
Route an observation through this split.
std::set< types::GroupId > node_groups() const override
Sorted set of group labels reachable from this node.
Definition TreeBranch.hpp:60
types::Outcome response() const override
Returns the response of the lower child.
std::unique_ptr< TreeBranch > Ptr
Definition TreeBranch.hpp:17
TreeNode::Ptr clone() const override
Deep copy of this node and its subtree.
bool equals(TreeNode const &other) const override
Structural equality comparison (value-based).
TreeNode::Ptr upper
Child node for observations with projected value ≥ cutpoint.
Definition TreeBranch.hpp:26
types::Feature cutpoint
Split cutpoint on the projected value.
Definition TreeBranch.hpp:22
void accept(TreeNode::Visitor &visitor) const override
Accept a tree node visitor (double dispatch).
static Ptr make(pp::Projector projector, types::Feature cutpoint, TreeNode::Ptr lower, TreeNode::Ptr upper, std::set< types::GroupId > groups={}, types::Feature pp_index_value=0)
Factory method that returns a unique_ptr to a new TreeBranch.
TreeBranch(pp::Projector projector, types::Feature cutpoint, TreeNode::Ptr lower, TreeNode::Ptr upper, std::set< types::GroupId > groups={}, types::Feature pp_index_value=0)
std::set< types::GroupId > groups
Set of group labels reachable from this node.
Definition TreeBranch.hpp:29
types::Feature pp_index_value
Projection pursuit index value achieved at this split.
Definition TreeBranch.hpp:31
pp::Projector projector
Projection vector (p). Defines the linear combination of features.
Definition TreeBranch.hpp:20
TreeNode::Ptr lower
Child node for observations with projected value < cutpoint.
Definition TreeBranch.hpp:24
int group_count() const override
Number of distinct groups reachable from this node.
Definition TreeBranch.hpp:58
Visitor interface for tree node dispatch.
Definition TreeNode.hpp:31
Abstract base class for nodes in a projection pursuit tree.
Definition TreeNode.hpp:19
std::unique_ptr< TreeNode > Ptr
Definition TreeNode.hpp:21
types::FeatureVector Projector
Column vector of projection coefficients (one per variable).
Definition Projector.hpp:6
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
float Feature
Scalar type for feature values.
Definition Types.hpp:24
Binarization strategies for multiclass-to-binary reduction.
Definition Benchmark.hpp:25