ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
Loading...
Searching...
No Matches
ppforest2::NodeContext Struct Reference

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::Featurecutpoint
 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::GroupIdlower_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::GroupPartitionlower_y_part
 Set by group: child partitions routed to the lower / upper child nodes.
 
std::optional< types::Featurepp_index_value
 Set by find_projection: projection pursuit index value achieved. std::nullopt before find_projection runs.
 
std::optional< Projectorprojector
 Set by find_projection: optimized projector (full dimension, expanded). std::nullopt before find_projection runs.
 
std::optional< types::GroupIdupper_group
 
std::optional< stats::GroupPartitionupper_y_part
 
std::optional< vars::VariableSelection::Resultvar_selection
 Set by select_vars: variable selection result. std::nullopt before select_vars runs.
 
types::FeatureMatrixx
 Full feature matrix.
 
stats::GroupPartition const & y
 Original G-group partition for this node.
 
std::optional< stats::GroupPartitiony_bin
 Set by regroup (multiclass → binary): 2-group binarized partition.
 
types::OutcomeVectory_vec
 Raw response vector whose row order matches x.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ NodeContext()

ppforest2::NodeContext::NodeContext ( types::FeatureMatrix & x,
stats::GroupPartition const & y,
types::OutcomeVector & y_vec,
int depth )
inline

Member Function Documentation

◆ active_partition()

stats::GroupPartition const & ppforest2::NodeContext::active_partition ( ) const
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.

Member Data Documentation

◆ aborted

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.

◆ cutpoint

std::optional<types::Feature> ppforest2::NodeContext::cutpoint

Set by find_cutpoint: split cutpoint in projected space. std::nullopt before find_cutpoint runs.

◆ depth

int ppforest2::NodeContext::depth

Depth of this node in the tree.

◆ lower_group

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.

◆ lower_y_part

std::optional<stats::GroupPartition> ppforest2::NodeContext::lower_y_part

Set by group: child partitions routed to the lower / upper child nodes.

◆ pp_index_value

std::optional<types::Feature> ppforest2::NodeContext::pp_index_value

Set by find_projection: projection pursuit index value achieved. std::nullopt before find_projection runs.

◆ projector

std::optional<Projector> ppforest2::NodeContext::projector

Set by find_projection: optimized projector (full dimension, expanded). std::nullopt before find_projection runs.

◆ upper_group

std::optional<types::GroupId> ppforest2::NodeContext::upper_group

◆ upper_y_part

std::optional<stats::GroupPartition> ppforest2::NodeContext::upper_y_part

◆ var_selection

std::optional<vars::VariableSelection::Result> ppforest2::NodeContext::var_selection

Set by select_vars: variable selection result. std::nullopt before select_vars runs.

◆ x

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.

◆ y

stats::GroupPartition const& ppforest2::NodeContext::y

Original G-group partition for this node.

◆ y_bin

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.

◆ y_vec

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.


The documentation for this struct was generated from the following file: