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

Namespaces

namespace  cli
 Command-line interface: argument parsing, subcommands, and benchmark/evaluation orchestration.
 
namespace  dr
 Dimensionality reduction strategies for variable selection.
 
namespace  io
 
namespace  math
 Numeric comparison utilities.
 
namespace  pp
 Projection pursuit strategies.
 
namespace  serialization
 JSON serialization and deserialization for ppforest2 models.
 
namespace  sr
 Split rule strategies for computing decision thresholds.
 
namespace  stats
 Statistical infrastructure for training and evaluation.
 
namespace  sys
 System-level utilities (process memory measurement).
 
namespace  types
 Core numeric type aliases for the ppforest2 library.
 
namespace  utils
 Utility functions for std::map manipulation.
 
namespace  viz
 

Classes

struct  BootstrapTree
 
struct  Forest
 A projection pursuit random forest. More...
 
struct  Model
 Abstract base class for predictive models (trees and forests). More...
 
struct  Proportions
 Tag type for requesting vote-proportion predictions. More...
 
struct  TrainingSpec
 Training configuration for projection pursuit trees and forests. More...
 
struct  Tree
 A single projection pursuit decision tree. More...
 
struct  TreeCondition
 Internal split node in a projection pursuit tree. More...
 
struct  TreeNode
 Abstract base class for nodes in a projection pursuit tree. More...
 
struct  TreeResponse
 Leaf node in a projection pursuit tree. More...
 
class  UserError
 Exception for user-facing input validation errors. More...
 
struct  VariableImportance
 Grouped result of the three variable importance measures. More...
 
struct  VIVisitor
 Visitor that accumulates per-variable contributions for VI2 and VI3. More...
 

Typedefs

using Threshold = types::Feature
 Scalar threshold type for split decisions.
 

Functions

void user_error (bool condition, char const *message)
 Throw a UserError if the condition is false.
 
void user_error (bool condition, std::string const &message)
 Throw a UserError if the condition is false.
 
void validate_json_keys (nlohmann::json const &j, std::string const &context, std::initializer_list< std::string > allowed)
 Validate that a JSON object contains only expected keys.
 
types::FeatureVector variable_importance_permuted (Forest const &forest, types::FeatureMatrix const &x, types::ResponseVector const &y, int seed=0)
 VI1 — Permuted importance.
 
types::FeatureVector variable_importance_projections (Forest const &forest, int n_vars, types::FeatureVector const *scale=nullptr)
 VI2 — Projections importance (forest).
 
types::FeatureVector variable_importance_projections (Tree const &tree, int n_vars, types::FeatureVector const *scale=nullptr)
 VI2 — Projections importance (single tree).
 
types::FeatureVector variable_importance_weighted_projections (Forest const &forest, types::FeatureMatrix const &x, types::ResponseVector const &y, types::FeatureVector const *scale=nullptr)
 VI3 — Weighted projections importance.
 

Typedef Documentation

◆ Threshold

Scalar threshold type for split decisions.

Function Documentation

◆ user_error() [1/2]

void ppforest2::user_error ( bool condition,
char const * message )

Throw a UserError if the condition is false.

Parameters
conditionCondition that must hold for valid input.
messageActionable error message for the user.

◆ user_error() [2/2]

void ppforest2::user_error ( bool condition,
std::string const & message )

Throw a UserError if the condition is false.

Parameters
conditionCondition that must hold for valid input.
messageActionable error message for the user.

◆ validate_json_keys()

void ppforest2::validate_json_keys ( nlohmann::json const & j,
std::string const & context,
std::initializer_list< std::string > allowed )
inline

Validate that a JSON object contains only expected keys.

Parameters
jThe JSON object to check.
contextHuman-readable strategy description (e.g. "PDA").
allowedSet of allowed key names.
Exceptions
std::runtime_errorif an unknown key is found.

◆ variable_importance_permuted()

types::FeatureVector ppforest2::variable_importance_permuted ( Forest const & forest,
types::FeatureMatrix const & x,
types::ResponseVector const & y,
int seed = 0 )

VI1 — Permuted importance.

For each tree, measures the drop in OOB accuracy when each variable is randomly permuted among the OOB observations. Results are averaged over all trees.

Parameters
forestTrained random forest.
xTraining feature matrix (n × p).
yTraining response vector (n).
seedRNG seed for the permutations.
Returns
FeatureVector of size p with per-variable importance.

◆ variable_importance_projections() [1/2]

types::FeatureVector ppforest2::variable_importance_projections ( Forest const & forest,
int n_vars,
types::FeatureVector const * scale = nullptr )

VI2 — Projections importance (forest).

At every split node s with G_s groups, accumulates |a_j| / G_s for each variable j. When scale is provided each |a_j| is first multiplied by σ_j so that coefficients are comparable across variables with different units. Results are averaged over all trees.

Parameters
forestTrained random forest.
n_varsNumber of predictor variables (p).
scaleOptional per-variable σ vector (size p).
Returns
FeatureVector of size p with per-variable importance.

◆ variable_importance_projections() [2/2]

types::FeatureVector ppforest2::variable_importance_projections ( Tree const & tree,
int n_vars,
types::FeatureVector const * scale = nullptr )

VI2 — Projections importance (single tree).

Same as the forest overload but for a single tree (no averaging).

Parameters
treeTrained tree.
n_varsNumber of predictor variables (p).
scaleOptional per-variable σ vector (size p).
Returns
FeatureVector of size p with per-variable importance.

◆ variable_importance_weighted_projections()

types::FeatureVector ppforest2::variable_importance_weighted_projections ( Forest const & forest,
types::FeatureMatrix const & x,
types::ResponseVector const & y,
types::FeatureVector const * scale = nullptr )

VI3 — Weighted projections importance.

Each tree's contribution is weighted by (1 − e_k), where e_k is its OOB error rate, and each split node contributes I_s × |a_j|. The result is normalised by B × (G − 1).

Parameters
forestTrained random forest.
xTraining feature matrix (n × p).
yTraining response vector (n).
scaleOptional per-variable σ vector (size p).
Returns
FeatureVector of size p with per-variable importance.