14template<ProgramType T>
57 this->is_fitted_ =
true;
73 template <ProgramType P = T>
76 template <ProgramType P = T>
117 {
"complexity", -1.0},
122 {
"average_precision_score", +1.0},
131 vector<float> weights;
136 weights.push_back(
it->second);
138 throw std::runtime_error(
139 "Unknown metric used as fitness. Value was " +
obj);
149template<ProgramType T>
153 {
"program",
p.program},
154 {
"fitness",
p.fitness},
156 {
"parent_id",
p.parent_id},
157 {
"objectives",
p.objectives}
161template<ProgramType T>
164 j.at(
"program").get_to(
p.program );
165 j.at(
"fitness").get_to(
p.fitness );
166 j.at(
"id").get_to(
p.id );
167 j.at(
"parent_id").get_to(
p.parent_id );
168 j.at(
"objectives").get_to(
p.objectives );
void bind_engine(py::module &m, string name)
holds variable type data.
static std::map< std::string, float > weightsMap
set parent ids using id values
unsigned int get_complexity() const
string get_model(string fmt="compact", bool pretty=false)
vector< string > objectives
objectives for use with Pareto selection
auto predict(const Dataset &data)
void set_fitness(Fitness &f)
auto predict_proba(const Dataset &d)
Individual< T > & fit(const Dataset &data)
unsigned int get_size() const
Program< T > & get_program()
VectorXf error
training error (used in lexicase selectors)
Fitness fitness
aggregate fitness score
Individual< T > & fit(const Ref< const ArrayXXf > &X, const Ref< const ArrayXf > &y)
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
ids of parents
auto predict(const Ref< const ArrayXXf > &X)
void init(SearchSpace &ss, const Parameters ¶ms)
Program< T > program
executable data structure
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)
An individual program, a.k.a. model.
TreeType predict_proba(const Dataset &d)
TreeType predict(const Dataset &d)
the standard predict function. Returns the output of the Tree directly.
int complexity() const
count the complexity of the program.
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.