4string TreeNode::get_model(
bool pretty)
 const  
    6    if (data.get_arg_count()==0)
 
    7        return data.get_name();
 
    9    vector<string> child_outputs;
 
   10    auto sib = first_child;
 
   11    for(
int i = 0; i < data.get_arg_count(); ++i)
 
   13        child_outputs.push_back(sib->get_model(pretty));
 
   14        sib = sib->next_sibling;
 
   16    return data.get_model(child_outputs);
 
   20string TreeNode::get_tree_model(
bool pretty, 
string offset)
 const  
   25    if (data.get_arg_count()==0)
 
   26        return data.get_name();
 
   28    string new_offset = 
"  ";
 
   29    string  child_outputs = 
"\n";
 
   31    auto sib = first_child;
 
   32    for(
int i = 0; i < data.get_arg_count(); ++i)
 
   34        child_outputs += 
offset + 
"|- ";
 
   35        string s = sib->get_tree_model(pretty, offset+new_offset);
 
   36        sib = sib->next_sibling;
 
   41            child_outputs += 
"\n";
 
   44        if (data.get_feature_type() != DataType::ArrayB) {
 
   45            return fmt::format(
"If({}>={:.2f})", data.get_feature(), data.W) + child_outputs;
 
   48            return fmt::format(
"If({})", data.get_feature()) + child_outputs;
 
   52        if (data.arg_types.at(0) == DataType::ArrayB)
 
   55            return "If" + child_outputs;
 
   59            return fmt::format(
"If(>={:.2f})", data.W) + child_outputs;
 
   63        return data.get_name() + child_outputs;
 
   72    for (
const auto &el : t)
 
 
   83    vector<tree<Node>> stack; 
 
   84    for (
int i = j.size(); i --> 0; )
 
   86        auto node = j.at(i).get<
Node>();
 
   88        auto root = subtree.insert(subtree.begin(), node);
 
   89        for (
auto at : node.arg_types)
 
   91            auto spot = subtree.append_child(root);
 
   92            auto arg = stack.back();
 
   93            subtree.move_ontop(spot, arg.begin());
 
   96        stack.push_back(subtree);
 
 
  104    {NodeType::Acos    ,  6},
 
  105    {NodeType::Asin    ,  6},
 
  106    {NodeType::Atan    ,  6},
 
  108    {NodeType::Cosh    ,  6},
 
  110    {NodeType::Sinh    ,  6},
 
  112    {NodeType::Tanh    ,  6},
 
  113    {NodeType::Ceil    ,  5},
 
  114    {NodeType::Floor   ,  5},
 
  117    {NodeType::Logabs  ,  10},
 
  118    {NodeType::Log1p   ,  9},
 
  119    {NodeType::Sqrt    ,  5},
 
  120    {NodeType::Sqrtabs ,  5},
 
  121    {NodeType::Square  ,  4},
 
  122    {NodeType::Logistic,  4},
 
  123    {NodeType::OffsetSum, 3},
 
  126    {NodeType::Before, 4},
 
  127    {NodeType::After , 4},
 
  128    {NodeType::During, 4},
 
  133    {NodeType::Mean     , 4},
 
  134    {NodeType::Median   , 4},
 
  136    {NodeType::Prod     , 4},
 
  139    {NodeType::Softmax, 5},
 
  149    {NodeType::SplitBest, 4},
 
  150    {NodeType::SplitOn  , 4},
 
  158    {NodeType::MeanLabel, 1},
 
  159    {NodeType::Constant , 2},
 
  160    {NodeType::Terminal , 3},
 
  161    {NodeType::ArgMax   , 5},
 
  162    {NodeType::Count    , 4},
 
  165    {NodeType::CustomUnaryOp , 5},
 
  166    {NodeType::CustomBinaryOp, 5},
 
  167    {NodeType::CustomSplit   , 5}
 
 
  170int TreeNode::get_linear_complexity()
 const  
  174    auto child = first_child;
 
  175    for(
int i = 0; i < data.get_arg_count(); ++i)
 
  177        tree_complexity += child->get_linear_complexity();
 
  178        child = child->next_sibling;
 
  182    if (data.get_is_weighted()
 
  193    return tree_complexity;
 
  196int TreeNode::get_complexity()
 const  
  199    int children_complexity_sum = 0; 
 
  201    auto child = first_child;
 
  202    for(
int i = 0; i < data.get_arg_count(); ++i)
 
  204        children_complexity_sum += child->get_complexity();
 
  205        child = child->next_sibling;
 
  209    children_complexity_sum = max(children_complexity_sum, 1);
 
  212    if (data.get_is_weighted()
 
  220                       node_complexity*(children_complexity_sum)
 
  224    return node_complexity*(children_complexity_sum);
 
  227int TreeNode::get_size(
bool include_weight)
 const  
  241    if ( (include_weight && data.get_is_weighted()==
true)
 
  247    auto child = first_child;
 
  248    for(
int i = 0; i < data.get_arg_count(); ++i)
 
  250        acc += child->get_size(include_weight);
 
  251        child = child->next_sibling;
 
void ReplaceStringInPlace(std::string &subject, const std::string &search, const std::string &replace)
string find and replace in place
 
auto Isnt(DataType dt) -> bool
 
void from_json(const json &j, Fitness &f)
 
auto Is(NodeType nt) -> bool
 
void to_json(json &j, const Fitness &f)
 
class holding the data for a node in a tree.
 
unordered_map< NodeType, int > operator_complexities