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

Free-function API for evaluating trained models — variable importance, out-of-bag diagnostics, and prediction error. More...

#include "stats/Metrics.hpp"
#include "utils/Types.hpp"
#include <memory>
#include <optional>

Go to the source code of this file.

Classes

struct  ppforest2::VariableImportance
 Grouped result of the variable importance measures. More...
 

Namespaces

namespace  ppforest2
 Binarization strategies for multiclass-to-binary reduction.
 

Functions

double ppforest2::error (Model const &model, types::FeatureMatrix const &x, types::OutcomeVector const &y)
 Prediction error of model on data (x, y).
 
template<typename T>
double ppforest2::error (std::unique_ptr< T > const &m, types::FeatureMatrix const &x, types::OutcomeVector const &y)
 
std::optional< double > ppforest2::oob_error (Forest const &forest, types::FeatureMatrix const &x, types::GroupIdVector const &y)
 Convenience overload — accepts integer class labels for classification.
 
std::optional< double > ppforest2::oob_error (Forest const &forest, types::FeatureMatrix const &x, types::OutcomeVector const &y)
 Out-of-bag error.
 
template<typename T>
std::optional< double > ppforest2::oob_error (std::unique_ptr< T > const &m, types::FeatureMatrix const &x, types::GroupIdVector const &y)
 
template<typename T>
std::optional< double > ppforest2::oob_error (std::unique_ptr< T > const &m, types::FeatureMatrix const &x, types::OutcomeVector const &y)
 
stats::ClassificationMetrics::Maybe ppforest2::oob_metrics (ClassificationForest const &forest, types::FeatureMatrix const &x, types::OutcomeVector const &y)
 Out-of-bag metrics — sentinel-free summary of OOB performance.
 
stats::RegressionMetrics::Maybe ppforest2::oob_metrics (RegressionForest const &forest, types::FeatureMatrix const &x, types::OutcomeVector const &y)
 
types::OutcomeVector ppforest2::oob_predict (Forest const &forest, types::FeatureMatrix const &x)
 Out-of-bag predictions.
 
template<typename T>
types::OutcomeVector ppforest2::oob_predict (std::unique_ptr< T > const &m, types::FeatureMatrix const &x)
 
VariableImportance ppforest2::variable_importance (Forest const &forest, types::FeatureMatrix const &x, types::OutcomeVector const &y, int seed)
 Bundle all three VI measures for a forest.
 
template<typename T>
VariableImportance ppforest2::variable_importance (std::unique_ptr< T > const &m, types::FeatureMatrix const &x)
 
template<typename T>
VariableImportance ppforest2::variable_importance (std::unique_ptr< T > const &m, types::FeatureMatrix const &x, types::OutcomeVector const &y, int seed)
 
VariableImportance ppforest2::variable_importance (Tree const &tree, types::FeatureMatrix const &x)
 Bundle the available VI measures for a single tree (VI2 only).
 
types::FeatureVector ppforest2::vi_permuted (Forest const &forest, types::FeatureMatrix const &x, types::OutcomeVector const &y, int seed)
 VI1 — per-variable permuted importance.
 
template<typename T>
types::FeatureVector ppforest2::vi_permuted (std::unique_ptr< T > const &m, types::FeatureMatrix const &x, types::OutcomeVector const &y, int seed)
 
types::FeatureVector ppforest2::vi_projections (Forest const &forest, int n_vars, types::FeatureVector const *scale=nullptr)
 VI2 for a forest — averaged over non-degenerate trees.
 
template<typename T>
types::FeatureVector ppforest2::vi_projections (std::unique_ptr< T > const &m, int n_vars, types::FeatureVector const *scale=nullptr)
 
types::FeatureVector ppforest2::vi_projections (Tree const &tree, int n_vars, types::FeatureVector const *scale=nullptr)
 VI2 for a single tree — projection-coefficient importance.
 
types::FeatureVector ppforest2::vi_weighted_projections (Forest const &forest, types::FeatureMatrix const &x, types::OutcomeVector const &y, types::FeatureVector const *scale=nullptr)
 VI3 — weighted projection-coefficient importance.
 
template<typename T>
types::FeatureVector ppforest2::vi_weighted_projections (std::unique_ptr< T > const &m, types::FeatureMatrix const &x, types::OutcomeVector const &y, types::FeatureVector const *scale=nullptr)
 

Detailed Description

Free-function API for evaluating trained models — variable importance, out-of-bag diagnostics, and prediction error.

Models (Tree, Forest and their concrete subclasses) own structure and prediction; everything else lives here as free functions that take a Model const&. Mode-specific dispatch goes through Model::Visitor, so callers don't need to know whether a forest is classification or regression — wrong-mode inputs raise UserError.

Mirrors the pattern already used by predict_proportions (in Model.hpp) and is_leaf (in TreeNode.hpp).