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

Namespaces

namespace  csv
 
namespace  json
 
namespace  layout
 Column-driven table formatting with ANSI-safe alignment.
 
namespace  style
 TTY-aware ANSI colored output utilities.
 

Classes

struct  ConfigDisplayHints
 Optional display hints for print_configuration. More...
 
struct  ModelStats
 Aggregated statistics across multiple training iterations. More...
 
struct  Output
 Quiet-aware, indentation-aware output context. More...
 
class  TempDir
 RAII temporary directory with automatic cleanup. More...
 
class  TempFile
 RAII temporary file with automatic cleanup. More...
 

Functions

void check_dir_not_exists (std::string const &path)
 Exit with an error if a directory already exists at the given path.
 
void check_file_not_exists (std::string const &path)
 Exit with an error if a file already exists at the given path.
 
template<typename F>
auto measure_time_ms (F &&f)
 Measure the wall-clock execution time of a callable in milliseconds.
 
std::string now_iso8601 ()
 Return the current local time as an ISO 8601 string (YYYY-MM-DDTHH:MM:SS).
 
void print_configuration (Output &out, nlohmann::json const &config, ConfigDisplayHints const &hints={})
 Print model configuration table from a JSON config object.
 
void print_confusion_matrix (Output &out, stats::ConfusionMatrix const &cm, std::string const &title="Confusion Matrix", std::vector< std::string > const &group_names={})
 Print a formatted confusion matrix to stdout.
 
void print_data_summary (Output &out, nlohmann::json const &meta)
 Print a data summary table from a JSON meta object.
 
void print_results (Output &out, ModelStats const &stats)
 Print evaluation results (timing, errors, memory) to stdout.
 
void print_summary (Output &out, nlohmann::json const &model_data, ConfigDisplayHints const &hints={})
 Display a full model summary from its JSON representation.
 
void print_variable_importance (Output &out, VariableImportance const &vi, std::vector< std::string > const &feature_names={}, int max_rows=20)
 Print a ranked variable importance table to stdout.
 

Function Documentation

◆ check_dir_not_exists()

void ppforest2::io::check_dir_not_exists ( std::string const & path)

Exit with an error if a directory already exists at the given path.

Parameters
pathThe directory path to check.

◆ check_file_not_exists()

void ppforest2::io::check_file_not_exists ( std::string const & path)

Exit with an error if a file already exists at the given path.

Parameters
pathThe file path to check.

◆ measure_time_ms()

template<typename F>
auto ppforest2::io::measure_time_ms ( F && f)

Measure the wall-clock execution time of a callable in milliseconds.

Template Parameters
FA callable (lambda, function pointer, std::function, etc.)
Parameters
fThe callable to time.
Returns
A pair of (result, duration_ms) where result is the return value of f() and duration_ms is the elapsed time in milliseconds.

◆ now_iso8601()

std::string ppforest2::io::now_iso8601 ( )
inline

Return the current local time as an ISO 8601 string (YYYY-MM-DDTHH:MM:SS).

◆ print_configuration()

void ppforest2::io::print_configuration ( Output & out,
nlohmann::json const & config,
ConfigDisplayHints const & hints = {} )

Print model configuration table from a JSON config object.

Parameters
outOutput context.
configThe config JSON (trees, lambda, seed, threads, vars, data).
hintsOptional display hints for richer output (defaults, percentages).

◆ print_confusion_matrix()

void ppforest2::io::print_confusion_matrix ( Output & out,
stats::ConfusionMatrix const & cm,
std::string const & title = "Confusion Matrix",
std::vector< std::string > const & group_names = {} )

Print a formatted confusion matrix to stdout.

Displays the confusion matrix with group labels, diagonal highlighting, and per-group error rates.

Parameters
outOutput context.
cmThe confusion matrix to print.

◆ print_data_summary()

void ppforest2::io::print_data_summary ( Output & out,
nlohmann::json const & meta )

Print a data summary table from a JSON meta object.

Shows observations, features, groups, and group names.

Parameters
outOutput context.
metaThe meta JSON (observations, features, groups).

◆ print_results()

void ppforest2::io::print_results ( Output & out,
ModelStats const & stats )

Print evaluation results (timing, errors, memory) to stdout.

Parameters
statsThe aggregated model statistics.

◆ print_summary()

void ppforest2::io::print_summary ( Output & out,
nlohmann::json const & model_data,
ConfigDisplayHints const & hints = {} )

Display a full model summary from its JSON representation.

Shows configuration, data summary, training/OOB confusion matrices, degenerate warnings, timing, and variable importance. Used by both run_train (after training) and run_summarize (from file).

◆ print_variable_importance()

void ppforest2::io::print_variable_importance ( Output & out,
VariableImportance const & vi,
std::vector< std::string > const & feature_names = {},
int max_rows = 20 )

Print a ranked variable importance table to stdout.

Columns: rank, variable name, sigma (scale), VI2 (projections), VI3 (weighted), VI1 (permuted). Rows are sorted by VI2 descending. The VI1 column is omitted when its vector is empty. At most max_rows rows are printed.

Parameters
outOutput context.
viVariable importance results.
max_rowsMaximum number of rows to print (0 = all).