common.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "node.h"
20 
21 #include <cstdint>
22 #include <map>
23 #include <string>
24 #include <vector>
25 
26 namespace cuml {
27 namespace genetic {
28 
30 enum class metric_t : uint32_t {
32  mae,
33 
35  mse,
36 
38  rmse,
39 
41  pearson,
42 
44  spearman,
45 
47  logloss,
48 }; // enum class metric_t
49 
51 enum class init_method_t : uint32_t {
53  grow,
54 
56  full,
57 
60 }; // enum class init_method_t
61 
62 enum class transformer_t : uint32_t {
64  sigmoid,
65 }; // enum class transformer_t
66 
68 enum class mutation_t : uint32_t {
70  none,
71 
73  crossover,
74 
76  subtree,
77 
79  hoist,
80 
82  point,
83 
85  reproduce
86 }; // enum class mutation_t
87 
94 struct param {
96  int population_size = 1000;
97 
102  int hall_of_fame = 100;
103 
108  int n_components = 10;
109 
111  int generations = 20;
112 
117  int tournament_size = 20;
118 
120  float stopping_criteria = 0.0f;
121 
123  float const_range[2] = {-1.0f, 1.0f};
124 
126  int init_depth[2] = {2, 6};
127 
130 
132  std::vector<node::type> function_set{
134 
136  std::map<int, std::vector<node::type>> arity_set{
143  float parsimony_coefficient = 0.001f;
145  float p_crossover = 0.9f;
147  float p_subtree_mutation = 0.01f;
149  float p_hoist_mutation = 0.01f;
150 
152  float p_point_mutation = 0.01f;
153 
155  float p_point_replace = 0.05f;
156 
158  float max_samples = 1.0f;
159 
161  float terminalRatio = 0.0f;
162 
164  std::vector<std::string> feature_names;
165 
170 
172  uint64_t random_state = 0UL;
173 
175  int num_epochs = 0;
176 
178  bool low_memory = false;
179 
181  float p_reproduce() const;
182 
184  int max_programs() const;
185 
187  int criterion() const;
188 }; // struct param
189 
190 } // namespace genetic
191 } // namespace cuml
metric_t
Definition: common.h:30
transformer_t
Definition: common.h:62
mutation_t
Definition: common.h:68
init_method_t
Definition: common.h:51
Definition: common.h:26
contains all the hyper-parameters for training
Definition: common.h:94
int population_size
Definition: common.h:96
int generations
Definition: common.h:111
bool low_memory
Definition: common.h:178
float p_crossover
Definition: common.h:145
int num_epochs
Definition: common.h:175
float p_point_replace
Definition: common.h:155
float max_samples
Definition: common.h:158
float p_subtree_mutation
Definition: common.h:147
int n_components
Definition: common.h:108
float stopping_criteria
Definition: common.h:120
uint64_t random_state
Definition: common.h:172
float const_range[2]
Definition: common.h:123
std::vector< std::string > feature_names
Definition: common.h:164
float p_hoist_mutation
Definition: common.h:149
std::map< int, std::vector< node::type > > arity_set
Definition: common.h:136
float terminalRatio
Definition: common.h:161
int num_features
Definition: common.h:167
metric_t metric
Definition: common.h:141
int tournament_size
Definition: common.h:117
int max_programs() const
float p_point_mutation
Definition: common.h:152
float p_reproduce() const
int init_depth[2]
Definition: common.h:126
transformer_t transformer
Definition: common.h:139
int hall_of_fame
Definition: common.h:102
float parsimony_coefficient
Definition: common.h:143
int criterion() const
init_method_t init_method
Definition: common.h:129
std::vector< node::type > function_set
Definition: common.h:132