|
ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
|
CRTP base class providing self-registration for strategy types. More...
#include <Strategy.hpp>
Public Types | |
| using | Factory = Ptr (*)(nlohmann::json const&) |
| Factory function type for deserializing a strategy from JSON. | |
| using | Ptr = std::shared_ptr<Derived> |
Public Member Functions | |
| virtual | ~Strategy ()=default |
| virtual std::string | display_name () const =0 |
| Human-readable name for display in summaries. | |
| virtual std::set< ppforest2::types::Mode > | supported_modes () const =0 |
| Training modes this strategy supports. | |
| virtual nlohmann::json | to_json () const =0 |
| Serialize this strategy's configuration to JSON. | |
Static Public Member Functions | |
| 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. | |
CRTP base class providing self-registration for strategy types.
Each strategy family (ProjectionPursuit, VariableSelection, Cutpoint, StopRule, Binarization, Grouping) inherits from Strategy<Derived> to get a shared_ptr Ptr typedef, a static registry of named factory functions, and a from_json() dispatcher that looks up the "name" field and delegates to the registered factory.
Concrete strategies register themselves at static-init time via the PPFOREST2_REGISTER_STRATEGY macro.
| Derived | The strategy base class (e.g. ProjectionPursuit). |
Factory function type for deserializing a strategy from JSON.
| using Strategy< Derived >::Ptr = std::shared_ptr<Derived> |
|
pure virtual |
Human-readable name for display in summaries.
Implemented in ppforest2::binarize::Disabled, ppforest2::binarize::LargestGap, ppforest2::cutpoint::MeanOfMeans, ppforest2::grouping::ByCutpoint, ppforest2::grouping::ByLabel, ppforest2::leaf::MajorityVote, ppforest2::leaf::MeanResponse, ppforest2::pp::PDA, ppforest2::stop::CompositeStop, ppforest2::stop::MaxDepth, ppforest2::stop::MinSize, ppforest2::stop::MinVariance, ppforest2::stop::PureNode, ppforest2::test::MockStop, ppforest2::vars::All, and ppforest2::vars::Uniform.
|
inlinestatic |
Construct a strategy from its JSON representation.
Dispatches on the "name" field to the registered factory.
| j | JSON object (must contain "name"). |
|
inlinestatic |
Register a concrete strategy for JSON deserialization.
Called automatically by concrete strategies via inline static initialization. Adding a new strategy only requires defining a static from_json and the PPFOREST2_REGISTER_STRATEGY macro.
| name | Strategy name (must match the "name" field in JSON). |
| factory | Factory function that constructs the strategy. |
|
pure virtual |
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.
Implemented in ppforest2::binarize::Disabled, ppforest2::binarize::LargestGap, ppforest2::cutpoint::MeanOfMeans, ppforest2::grouping::ByCutpoint, ppforest2::grouping::ByLabel, ppforest2::leaf::MajorityVote, ppforest2::leaf::MeanResponse, ppforest2::pp::PDA, ppforest2::stop::CompositeStop, ppforest2::stop::MaxDepth, ppforest2::stop::MinSize, ppforest2::stop::MinVariance, ppforest2::stop::PureNode, ppforest2::test::MockStop, ppforest2::vars::All, and ppforest2::vars::Uniform.
|
pure virtual |
Serialize this strategy's configuration to JSON.
Must include a "name" field identifying the strategy type, plus any strategy-specific parameters.
Implemented in ppforest2::binarize::Disabled, ppforest2::binarize::LargestGap, ppforest2::cutpoint::MeanOfMeans, ppforest2::grouping::ByCutpoint, ppforest2::grouping::ByLabel, ppforest2::leaf::MajorityVote, ppforest2::leaf::MeanResponse, ppforest2::pp::PDA, ppforest2::stop::CompositeStop, ppforest2::stop::MaxDepth, ppforest2::stop::MinSize, ppforest2::stop::MinVariance, ppforest2::stop::PureNode, ppforest2::test::MockStop, ppforest2::vars::All, and ppforest2::vars::Uniform.