|
| bool | has_value (nlohmann::json const &j, std::string_view key) |
| | True iff j has a non-null value at key.
|
| |
| json | to_json (types::OutcomeVector const &y, types::Names const &names) |
| | Serialize a prediction vector as JSON.
|
| |
| void | validate_forest_export (nlohmann::json const &j) |
| | Validate the structural shape of a loaded model Export JSON.
|
| |
| void | validate_tree_export (nlohmann::json const &j) |
| | Validate the structural shape of a loaded model Export JSON.
|
| |
|
| json | to_json (Model const &model) |
| |
| json | to_json (TreeNode const &node) |
| |
| json | to_json (Tree const &tree) |
| |
| json | to_json (BaggedTree const &tree) |
| |
| json | to_json (Forest const &forest) |
| |
| json | to_json (stats::ConfusionMatrix const &cm) |
| |
| json | to_json (stats::ClassificationMetrics const &cm) |
| |
| json | to_json (VariableImportance const &vi) |
| |
| json | to_json (stats::RegressionMetrics const &rm) |
| |
| json | to_json (Metrics const &metrics) |
| |
| json | to_json (types::FeatureMatrix const &matrix) |
| |
|
| json | to_json (Model const &model, Names const &group_names) |
| |
| json | to_json (TreeNode const &node, Names const &group_names) |
| |
| json | to_json (Tree const &tree, Names const &group_names) |
| |
| json | to_json (BaggedTree const &tree, Names const &group_names) |
| |
| json | to_json (Forest const &forest, Names const &group_names) |
| |
| json | to_json (stats::ConfusionMatrix const &cm, Names const &group_names) |
| |
| json | to_json (stats::ClassificationMetrics const &cm, Names const &group_names) |
| |
| json | to_json (stats::RegressionMetrics const &rm, Names const &group_names) |
| |
| json | to_json (Metrics const &metrics, Names const &group_names) |
| |
|
| json | to_json (std::optional< VariableImportance > const &vi) |
| |
| json | to_json (std::optional< Metrics > const &metrics) |
| |
| json | to_json (std::optional< Metrics > const &metrics, Names const &group_names) |
| |
|
| template<typename T> |
| T | from_json (json const &j) |
| | Deserialize a value block (confusion matrix, VI, metrics, …).
|
| |
| template<> |
| stats::ConfusionMatrix | from_json< stats::ConfusionMatrix > (json const &j) |
| |
| template<> |
| stats::ClassificationMetrics | from_json< stats::ClassificationMetrics > (json const &j) |
| |
| template<> |
| VariableImportance | from_json< VariableImportance > (json const &j) |
| |
| template<> |
| stats::RegressionMetrics | from_json< stats::RegressionMetrics > (json const &j) |
| |
| Metrics | metrics_from_json (json const &j, types::Mode mode) |
| | Deserialize a Metrics block; mode picks the variant alternative.
|
| |
|
| std::ostream & | operator<< (std::ostream &os, TreeNode const &node) |
| |
| std::ostream & | operator<< (std::ostream &os, TreeBranch const &condition) |
| |
| std::ostream & | operator<< (std::ostream &os, TreeLeaf const &response) |
| |
| std::ostream & | operator<< (std::ostream &os, Tree const &tree) |
| |
| std::ostream & | operator<< (std::ostream &os, Forest const &forest) |
| |
| template<typename V> |
| std::ostream & | operator<< (std::ostream &ostream, std::vector< V > const &vec) |
| |
| template<typename V, typename C1, typename C2> |
| std::ostream & | operator<< (std::ostream &ostream, std::set< V, C1, C2 > const &set) |
| |
| template<typename K, typename V> |
| std::ostream & | operator<< (std::ostream &ostream, std::map< K, V > const &map) |
| |
| template<typename V> |
| std::ostream & | operator<< (std::ostream &ostream, std::map< int, V > const &map) |
| |
JSON serialization and deserialization for ppforest2 models.
Uses nlohmann/json. Provides to_json() for serializing trees, forests, confusion matrices, and variable importance to JSON. Deserialization uses j.get<T>() via nlohmann ADL:
io::json::write_file(j, "model.json");
auto j2 = io::json::read_file("model.json");
Abstract base class for projection pursuit decision trees.
Definition Tree.hpp:29
json to_json(types::OutcomeVector const &y, types::Names const &names)
Serialize a prediction vector as JSON.
A model bundled with its export metadata and optional metrics.
Definition Json.hpp:57
| void ppforest2::serialization::validate_forest_export |
( |
nlohmann::json const & | j | ) |
|
Validate the structural shape of a loaded model Export JSON.
Runs before any from_json decoding so failures surface with domain-specific, path-annotated messages instead of nlohmann's cryptic type errors.
Concentrates every cross-field and required-field check in one place. Strategy internals are not validated here — each strategy's own from_json performs that via JsonReader. This keeps the validator responsibilities flat (skeleton + config + meta + variant-specific model block) and avoids turning it into a schema library.
Each validator asserts model_type == "tree" / "forest" matches the call site; mismatches throw a UserError.
- Exceptions
-
| UserError | with a dotted path on validation failure. |
| void ppforest2::serialization::validate_tree_export |
( |
nlohmann::json const & | j | ) |
|
Validate the structural shape of a loaded model Export JSON.
Runs before any from_json decoding so failures surface with domain-specific, path-annotated messages instead of nlohmann's cryptic type errors.
Concentrates every cross-field and required-field check in one place. Strategy internals are not validated here — each strategy's own from_json performs that via JsonReader. This keeps the validator responsibilities flat (skeleton + config + meta + variant-specific model block) and avoids turning it into a schema library.
Each validator asserts model_type == "tree" / "forest" matches the call site; mismatches throw a UserError.
- Exceptions
-
| UserError | with a dotted path on validation failure. |