ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
Loading...
Searching...
No Matches
ModelParams.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include <nlohmann/json.hpp>
8#include <optional>
9#include <string>
10#include <vector>
11
12namespace ppforest2::cli {
14 struct ModelParams {
15 ModelParams() = default;
16
17 int size = 100;
18 float lambda = 0.0;
19 std::optional<int> threads;
20 std::optional<int> seed;
21 std::optional<float> p_vars;
22 std::optional<int> n_vars;
23 int max_retries = 3;
24 std::string p_vars_input;
25
34 std::string mode_input;
35
37 std::string pp_input;
38 std::string vars_input;
39 std::string cutpoint_input;
47 std::vector<std::string> stop_inputs;
48 std::string binarize_input;
49 std::string grouping_input;
50 std::string leaf_input;
51
53 nlohmann::json pp_config;
54 nlohmann::json vars_config;
55 nlohmann::json cutpoint_config;
56 nlohmann::json stop_config;
57 nlohmann::json binarize_config;
58 nlohmann::json grouping_config;
59 nlohmann::json leaf_config;
60
62 explicit ModelParams(nlohmann::json const& config);
63
65 void resolve();
66
68 void resolve_defaults(unsigned int total_vars);
69
71 static void validate(nlohmann::json const& config, std::vector<std::string>& errors);
72
74 nlohmann::json to_json() const;
75 };
76
88 float parse_proportion(std::string const& input);
89 float parse_proportion(nlohmann::json const& j);
90
96 nlohmann::json strategy_string_to_json(std::string const& input);
97}
Command-line interface: argument parsing, subcommands, and benchmark/evaluation orchestration.
Definition Benchmark.hpp:25
nlohmann::json strategy_string_to_json(std::string const &input)
Parse a CLI strategy string into a JSON object.
float parse_proportion(std::string const &input)
Parse a proportion from a string or JSON value.
void resolve()
Parse strategy input strings and p_vars input into their final form.
std::optional< int > threads
Definition ModelParams.hpp:19
float lambda
Definition ModelParams.hpp:18
int size
Definition ModelParams.hpp:17
std::optional< int > seed
Definition ModelParams.hpp:20
std::string cutpoint_input
Definition ModelParams.hpp:39
nlohmann::json vars_config
Definition ModelParams.hpp:54
ModelParams(nlohmann::json const &config)
Construct from a JSON config object.
nlohmann::json grouping_config
Definition ModelParams.hpp:58
nlohmann::json leaf_config
Definition ModelParams.hpp:59
std::string pp_input
Explicit strategy inputs (–X flags).
Definition ModelParams.hpp:37
std::string p_vars_input
Definition ModelParams.hpp:24
nlohmann::json stop_config
Definition ModelParams.hpp:56
nlohmann::json to_json() const
Serialize to JSON config.
nlohmann::json cutpoint_config
Definition ModelParams.hpp:55
int max_retries
Definition ModelParams.hpp:23
std::string grouping_input
Definition ModelParams.hpp:49
nlohmann::json binarize_config
Definition ModelParams.hpp:57
std::string leaf_input
Definition ModelParams.hpp:50
std::string binarize_input
Definition ModelParams.hpp:48
std::optional< float > p_vars
Definition ModelParams.hpp:21
static void validate(nlohmann::json const &config, std::vector< std::string > &errors)
Validate model-related fields in a JSON config.
std::optional< int > n_vars
Definition ModelParams.hpp:22
std::string mode_input
Training mode ("classification" or "regression").
Definition ModelParams.hpp:34
nlohmann::json pp_config
Strategy JSON objects (from CLI strings or config file).
Definition ModelParams.hpp:53
std::string vars_input
Definition ModelParams.hpp:38
std::vector< std::string > stop_inputs
Repeated --stop flag values.
Definition ModelParams.hpp:47
void resolve_defaults(unsigned int total_vars)
Fill in runtime defaults (threads, vars, strategy configs).