ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
Loading...
Searching...
No Matches
ppforest2::grouping::ByCutpoint Class Reference

Cutpoint-based grouping for regression trees. More...

#include <ByCutpoint.hpp>

Public Member Functions

std::string display_name () const override
 Human-readable name for display in summaries.
 
std::set< types::Modesupported_modes () const override
 Training modes this strategy supports.
 
nlohmann::json to_json () const override
 Serialize this strategy's configuration to JSON.
 
- Public Member Functions inherited from ppforest2::grouping::Grouping
stats::GroupPartition init (types::GroupIdVector const &y) const
 Convenience overload for callers with a GroupIdVector.
 
stats::GroupPartition init (types::OutcomeVector const &y) const
 Create the initial GroupPartition from the training response.
 
void split (NodeContext &ctx, stats::RNG &rng) const
 Split observations into two child partitions; writes ctx.lower_y_part / upper_y_part.
 
- Public Member Functions inherited from Strategy< Grouping >
virtual ~Strategy ()=default
 

Static Public Member Functions

static Grouping::Ptr from_json (nlohmann::json const &j)
 
- Static Public Member Functions inherited from Strategy< Grouping >
static Ptr from_json (nlohmann::json const &j)
 Construct a strategy from its JSON representation.
 
static bool register_strategy (std::string const &name, Factory factory)
 Register a concrete strategy for JSON deserialization.
 

Protected Member Functions

void compute (NodeContext &ctx, stats::RNG &rng) const override
 Split observations by cutpoint and re-cluster each child.
 
stats::GroupPartition compute_init (types::OutcomeVector const &y) const override
 Median-split the sorted continuous response into 2 groups.
 

Additional Inherited Members

- Public Types inherited from Strategy< Grouping >
using Factory
 Factory function type for deserializing a strategy from JSON.
 
using Ptr
 

Detailed Description

Cutpoint-based grouping for regression trees.

At each node, observations are split by the cutpoint in projected space, then each child's observations are sorted by continuous_y and median-split into 2 artificial groups for the next PDA projection.

Requires the non-const ctx.x and ctx.y_vec on NodeContext for in-place reordering of data within each node's range.

  • init(): wraps pre-computed GroupIdVector (median-split of sorted y) into a GroupPartition (same as ByLabel).
  • split(): partitions observations by cutpoint, re-sorts each child by continuous_y, median-splits into 2 groups.

Member Function Documentation

◆ compute()

void ppforest2::grouping::ByCutpoint::compute ( NodeContext & ctx,
stats::RNG & rng ) const
overrideprotectedvirtual

Split observations by cutpoint and re-cluster each child.

Requires the non-const ctx.x and ctx.y_vec on the context.

  1. Partitions rows within the node's range by projected value vs cutpoint.
  2. Sorts each child's rows by continuous_y.
  3. Median-splits each child into 2 groups.

Implements ppforest2::grouping::Grouping.

◆ compute_init()

stats::GroupPartition ppforest2::grouping::ByCutpoint::compute_init ( types::OutcomeVector const & y) const
overrideprotectedvirtual

Median-split the sorted continuous response into 2 groups.

The caller must pre-sort y ascending. For n >= 2 the result is GroupPartition(0, n - 1).bisect(n / 2); for n == 1 a single-group partition covering [0, 0] is returned.

Implements ppforest2::grouping::Grouping.

◆ display_name()

std::string ppforest2::grouping::ByCutpoint::display_name ( ) const
inlineoverridevirtual

Human-readable name for display in summaries.

Implements Strategy< Grouping >.

◆ from_json()

static Grouping::Ptr ppforest2::grouping::ByCutpoint::from_json ( nlohmann::json const & j)
static

◆ supported_modes()

std::set< types::Mode > ppforest2::grouping::ByCutpoint::supported_modes ( ) const
inlineoverridevirtual

Training modes this strategy supports.

Every concrete strategy MUST explicitly declare which modes it supports — there is no default. This forces implementers to think about mode compatibility rather than silently inheriting both modes and triggering runtime surprises.

Used by TrainingSpec to validate that every selected strategy is compatible with the configured training mode. Fails fast at build time instead of silently misbehaving at train time.

Implements Strategy< Grouping >.

◆ to_json()

nlohmann::json ppforest2::grouping::ByCutpoint::to_json ( ) const
overridevirtual

Serialize this strategy's configuration to JSON.

Must include a "name" field identifying the strategy type, plus any strategy-specific parameters.

Implements Strategy< Grouping >.


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