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

Training configuration for projection pursuit trees and forests. More...

#include <TrainingSpec.hpp>

Public Types

using Ptr = std::shared_ptr<TrainingSpec>
 

Public Member Functions

 TrainingSpec (pp::PPStrategy::Ptr pp, dr::DRStrategy::Ptr dr, sr::SRStrategy::Ptr sr, int size=0, int seed=0, int threads=0, int max_retries=3)
 Construct a training specification.
 
bool is_forest () const
 Whether this specification describes a forest (size > 0).
 
int resolve_threads () const
 Get the number of threads to use for training.
 
void to_json (nlohmann::json &j) const
 Serialize the training spec to JSON.
 

Static Public Member Functions

static Ptr from_json (nlohmann::json const &j)
 Deserialize a training spec from JSON.
 
template<typename... Args>
static Ptr make (Args &&... args)
 Create a shared pointer to a TrainingSpec.
 

Public Attributes

dr::DRStrategy::Ptr const dr_strategy
 Dimensionality reduction strategy.
 
int const max_retries
 Maximum retry attempts for degenerate trees.
 
pp::PPStrategy::Ptr const pp_strategy
 Projection pursuit optimization strategy.
 
int const seed
 RNG seed.
 
int const size
 Number of trees (0 = single tree).
 
sr::SRStrategy::Ptr const sr_strategy
 Group splitting rule strategy.
 
int const threads
 Number of threads for parallel forest training.
 

Detailed Description

Training configuration for projection pursuit trees and forests.

Composes a projection pursuit strategy (PPStrategy), a dimensionality reduction strategy (DRStrategy), and a split strategy (SRStrategy), together with forest-level parameters (size, seed, threads, max retries).

TrainingSpec is a concrete class — new strategies are plugged in via the constructor, not by subclassing:

// Single tree with PDA:
// Random forest with uniform variable selection:
100, 0); // size, seed
// Custom strategy:
TrainingSpec spec(my_custom_pp(), dr::uniform(5), sr::mean_of_means(),
200, 7); // size, seed
DRStrategy::Ptr uniform(int n_vars)
Factory function for a uniform DR strategy.
DRStrategy::Ptr noop()
Factory function for a no-op DR strategy.
PPStrategy::Ptr pda(float lambda)
Factory function for a PDA projection pursuit strategy.
SRStrategy::Ptr mean_of_means()
Factory function for a mean-of-means split strategy.
TrainingSpec(pp::PPStrategy::Ptr pp, dr::DRStrategy::Ptr dr, sr::SRStrategy::Ptr sr, int size=0, int seed=0, int threads=0, int max_retries=3)
Construct a training specification.

Strategies are held via shared_ptr and are immutable after construction, so TrainingSpec can be freely copied and shared across trees without deep cloning.

Member Typedef Documentation

◆ Ptr

using ppforest2::TrainingSpec::Ptr = std::shared_ptr<TrainingSpec>

Constructor & Destructor Documentation

◆ TrainingSpec()

ppforest2::TrainingSpec::TrainingSpec ( pp::PPStrategy::Ptr pp,
dr::DRStrategy::Ptr dr,
sr::SRStrategy::Ptr sr,
int size = 0,
int seed = 0,
int threads = 0,
int max_retries = 3 )

Construct a training specification.

Parameters
ppProjection pursuit strategy.
drDimensionality reduction strategy.
srSplit rule strategy.
sizeNumber of trees (0 = single tree).
seedRNG seed.
threadsNumber of threads (0 = hardware concurrency).
max_retriesMaximum retry attempts for degenerate trees.

Member Function Documentation

◆ from_json()

static Ptr ppforest2::TrainingSpec::from_json ( nlohmann::json const & j)
static

Deserialize a training spec from JSON.

◆ is_forest()

bool ppforest2::TrainingSpec::is_forest ( ) const
inline

Whether this specification describes a forest (size > 0).

◆ make()

template<typename... Args>
static Ptr ppforest2::TrainingSpec::make ( Args &&... args)
inlinestatic

Create a shared pointer to a TrainingSpec.

Convenience factory that forwards all arguments to the constructor.

Returns
Shared pointer to a new TrainingSpec.

◆ resolve_threads()

int ppforest2::TrainingSpec::resolve_threads ( ) const
inline

Get the number of threads to use for training.

If the number of threads is not specified, the number of hardware concurrency is returned.

Returns
The number of threads to use for training.

◆ to_json()

void ppforest2::TrainingSpec::to_json ( nlohmann::json & j) const

Serialize the training spec to JSON.

Member Data Documentation

◆ dr_strategy

dr::DRStrategy::Ptr const ppforest2::TrainingSpec::dr_strategy

Dimensionality reduction strategy.

◆ max_retries

int const ppforest2::TrainingSpec::max_retries

Maximum retry attempts for degenerate trees.

◆ pp_strategy

pp::PPStrategy::Ptr const ppforest2::TrainingSpec::pp_strategy

Projection pursuit optimization strategy.

◆ seed

int const ppforest2::TrainingSpec::seed

RNG seed.

◆ size

int const ppforest2::TrainingSpec::size

Number of trees (0 = single tree).

◆ sr_strategy

sr::SRStrategy::Ptr const ppforest2::TrainingSpec::sr_strategy

Group splitting rule strategy.

◆ threads

int const ppforest2::TrainingSpec::threads

Number of threads for parallel forest training.


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