14template<ProgramType T>
69 this->is_fitted_ =
true;
87 this->is_fitted_ =
false;
111 template <ProgramType P = T>
114 template <ProgramType P = T>
129 string get_model(
string fmt=
"compact",
bool pretty=
false) {
150 for (
const auto& p : parents)
164 {
"complexity", -1.0},
165 {
"linear_complexity", -1.0},
170 {
"average_precision_score", +1.0},
171 {
"balanced_accuracy", +1.0},
183 vector<float> weights;
188 weights.push_back(it->second);
190 throw std::runtime_error(
191 "Unknown metric used as fitness. Value was " + obj);
201template<ProgramType T>
216template<ProgramType T>
219 j.at(
"program").get_to( p.
program );
220 j.at(
"fitness").get_to( p.
fitness );
221 j.at(
"id").get_to( p.
id );
holds variable type data.
vector< Node > sampled_nodes
static std::map< std::string, float > weightsMap
void set_is_fitted(bool fitted)
unsigned int get_complexity() const
Individual< T > & replace_program(const Program< T > &new_program)
Replace the current program with a new program, invalidating fitness.
string get_model(string fmt="compact", bool pretty=false)
vector< string > objectives
auto predict(const Dataset &data)
void set_fitness(Fitness &f)
auto predict_proba(const Dataset &d)
Individual< T > & fit(const Dataset &data)
void set_variation(string v)
void set_sampled_nodes(const vector< Node > &nodes)
unsigned int get_size() const
Program< T > & get_program()
vector< Node > get_sampled_nodes() const
Individual< T > & fit(const Ref< const ArrayXXf > &X, const Ref< const ArrayXf > &y)
string get_variation() const
void set_parents(const vector< unsigned > &parents)
set parent ids using parents
string get_dot_model(string extras="")
vector< string > get_objectives() const
auto predict_proba(const Ref< const ArrayXXf > &X)
void set_objectives(vector< string > objs)
void set_parents(const vector< Individual< T > > &parents)
Individual(Program< T > &prg)
unsigned int get_depth() const
vector< unsigned > parent_id
auto predict(const Ref< const ArrayXXf > &X)
unsigned int get_linear_complexity() const
Individual< T > & replace_program(const json &j)
Replace the current program from a JSON representation, invalidating fitness.
void init(SearchSpace &ss, const Parameters ¶ms)
bool get_is_fitted() const
void to_json(json &j, const Individual< T > &p)
void from_json(const json &j, Individual< T > &p)
< nsga2 selection operator for getting the front
Represents the fitness of an individual in the Brush namespace.
void set_weights(vector< float > &w)
vector< string > get_objectives() const
An individual program, a.k.a. model.
TreeType predict_proba(const Dataset &d)
int linear_complexity() const
count the linear complexity of the program.
TreeType predict(const Dataset &d)
the standard predict function. Returns the output of the Tree directly.
int complexity() const
count the (recursive) complexity of the program.
Program< PType > & replace_program(const Program< PType > &new_program)
Replace the current program with a new program, invalidating fitness.
Program< PType > & fit(const Dataset &d)
int depth() const
count the tree depth of the program. The depth is not influenced by weighted nodes.
string get_dot_model(string extras="") const
Get the model as a dot object.
string get_model(string fmt="compact", bool pretty=false) const
Get the model as a string.
int size(bool include_weight=true) const
count the tree size of the program, including the weights in weighted nodes.
Holds a search space, consisting of operations and terminals and functions, and methods to sample tha...
PT make_program(const Parameters ¶ms, int max_d=0, int max_size=0)
Makes a random program.