|
ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
|
Mutable context accumulating intermediate results during node training. More...
#include <NodeContext.hpp>
Public Member Functions | |
| NodeContext (types::FeatureMatrix &x, stats::GroupPartition const &y, types::OutcomeVector &y_vec, int depth) | |
| stats::GroupPartition const & | active_partition () const |
| Return the active group partition. | |
Public Attributes | |
| bool | aborted = false |
| Sticky abort flag for the per-node strategy pipeline. | |
| std::optional< types::Feature > | cutpoint |
Set by find_cutpoint: split cutpoint in projected space. std::nullopt before find_cutpoint runs. | |
| int | depth |
| Depth of this node in the tree. | |
| std::optional< types::GroupId > | lower_group |
Set by find_cutpoint: labels of the two groups in active_partition(), oriented so lower_group's projected mean < upper_group's. | |
| std::optional< stats::GroupPartition > | lower_y_part |
| Set by group: child partitions routed to the lower / upper child nodes. | |
| std::optional< types::Feature > | pp_index_value |
Set by find_projection: projection pursuit index value achieved. std::nullopt before find_projection runs. | |
| std::optional< Projector > | projector |
Set by find_projection: optimized projector (full dimension, expanded). std::nullopt before find_projection runs. | |
| std::optional< types::GroupId > | upper_group |
| std::optional< stats::GroupPartition > | upper_y_part |
| std::optional< vars::VariableSelection::Result > | var_selection |
Set by select_vars: variable selection result. std::nullopt before select_vars runs. | |
| types::FeatureMatrix & | x |
| Full feature matrix. | |
| stats::GroupPartition const & | y |
| Original G-group partition for this node. | |
| std::optional< stats::GroupPartition > | y_bin |
| Set by regroup (multiclass → binary): 2-group binarized partition. | |
| types::OutcomeVector & | y_vec |
Raw response vector whose row order matches x. | |
Mutable context accumulating intermediate results during node training.
Starts with node-level data (x, y, depth) and accumulates results as each strategy in the training pipeline executes. Each strategy reads what it needs and writes its results back.
|
inline |
|
inline |
Return the active group partition.
After binarization, returns the binary partition (2 groups). Before binarization (or for 2-group nodes), returns the original partition.
| bool ppforest2::NodeContext::aborted = false |
Sticky abort flag for the per-node strategy pipeline.
When a producer step detects a degenerate outcome (NaN projector, fewer than 2 binary groups, etc.), it sets this flag. Subsequent strategies called on the same context skip their work — every strategy's public NVI entry point checks this first before dispatching to the subclass compute. The orchestrator (Tree::build_root) then converts the aborted context into a degenerate leaf with a single check at the end of the node step.
| std::optional<types::Feature> ppforest2::NodeContext::cutpoint |
Set by find_cutpoint: split cutpoint in projected space. std::nullopt before find_cutpoint runs.
| int ppforest2::NodeContext::depth |
Depth of this node in the tree.
| std::optional<types::GroupId> ppforest2::NodeContext::lower_group |
Set by find_cutpoint: labels of the two groups in active_partition(), oriented so lower_group's projected mean < upper_group's.
Consumed by Grouping::split to route rows to lower/upper children.
| std::optional<stats::GroupPartition> ppforest2::NodeContext::lower_y_part |
Set by group: child partitions routed to the lower / upper child nodes.
| std::optional<types::Feature> ppforest2::NodeContext::pp_index_value |
Set by find_projection: projection pursuit index value achieved. std::nullopt before find_projection runs.
| std::optional<Projector> ppforest2::NodeContext::projector |
Set by find_projection: optimized projector (full dimension, expanded). std::nullopt before find_projection runs.
| std::optional<types::GroupId> ppforest2::NodeContext::upper_group |
| std::optional<stats::GroupPartition> ppforest2::NodeContext::upper_y_part |
| std::optional<vars::VariableSelection::Result> ppforest2::NodeContext::var_selection |
Set by select_vars: variable selection result. std::nullopt before select_vars runs.
| types::FeatureMatrix& ppforest2::NodeContext::x |
Full feature matrix.
Non-const because regression's ByCutpoint grouping strategy reorders rows in place within each node's range. Classification strategies only read — there's no mode-specific subtype, so the const promise lives at the strategy level, not in the context.
| stats::GroupPartition const& ppforest2::NodeContext::y |
Original G-group partition for this node.
| std::optional<stats::GroupPartition> ppforest2::NodeContext::y_bin |
Set by regroup (multiclass → binary): 2-group binarized partition.
std::nullopt on binary nodes (no binarization needed). Consumers should read via active_partition(), which falls back to y.
| types::OutcomeVector& ppforest2::NodeContext::y_vec |
Raw response vector whose row order matches x.
Regression strategies (MeanResponse leaf, MinVariance stop, ByCutpoint grouping) read or reorder it; classification strategies ignore it. Non-const for the same reason as x.