Individual and Fitness

Contents

Individual and Fitness#

template<ProgramType T>
class Individual#

Public Functions

inline Individual()#
inline Individual(Program<T> &prg)#
inline void init(SearchSpace &ss, const Parameters &params)#
inline Individual<T> &fit(const Dataset &data)#
inline Individual<T> &fit(const Ref<const ArrayXXf> &X, const Ref<const ArrayXf> &y)#
inline auto predict(const Dataset &data)#
inline auto predict(const Ref<const ArrayXXf> &X)#
template<ProgramType P = T>
inline auto predict_proba(const Dataset &d)#
template<ProgramType P = T>
inline auto predict_proba(const Ref<const ArrayXXf> &X)#
inline bool get_is_fitted() const#
inline unsigned int get_size() const#
inline unsigned int get_depth() const#
inline unsigned int get_complexity() const#
inline Program<T> &get_program()#
inline string get_model(string fmt = "compact", bool pretty = false)#
inline string get_dot_model(string extras = "")#
inline void set_fitness(Fitness &f)#
inline Fitness &get_fitness()#
inline void set_id(unsigned i)#
inline void set_parents(const vector<Individual<T>> &parents)#
inline void set_parents(const vector<unsigned> &parents)#

set parent ids using parents

inline vector<string> get_objectives() const#
inline void set_objectives(vector<string> objs)#

Public Members

Program<T> program#

executable data structure

bool is_fitted_ = false#
unsigned id#

tracking id

vector<unsigned> parent_id#

ids of parents

VectorXf error#

training error (used in lexicase selectors)

Fitness fitness#

aggregate fitness score

vector<string> objectives#

objectives for use with Pareto selection

Public Static Attributes

static std::map<std::string, float> weightsMap = {{"complexity", -1.0}, {"size", -1.0}, {"mse", -1.0}, {"log", -1.0}, {"multi_log", -1.0}, {"average_precision_score", +1.0}, {"accuracy", +1.0}, {"error", -1.0}}#

set parent ids using id values

struct Fitness#

Represents the fitness of an individual in the Brush namespace.

The Fitness struct stores various attributes related to the fitness of an individual in the Brush namespace. It includes the aggregate loss score, aggregate validation loss score, complexity, size, depth, dominance counter, dominated individuals, Pareto front rank, crowding distance on the Pareto front, weighted values, and weights.

The struct provides getter and setter methods for accessing and modifying these attributes. It also includes methods for calculating the hash value, setting values, clearing values, checking validity, and performing comparison operations.

Additionally, there are methods for converting the Fitness object to JSON format and vice versa.

Public Functions

inline void set_dominated(vector<unsigned int> &dom)#
inline vector<unsigned int> get_dominated() const#
inline void set_loss(float f)#
inline float get_loss() const#
inline void set_loss_v(float f_v)#
inline float get_loss_v() const#
inline void set_size(unsigned int new_s)#
inline unsigned int get_size() const#
inline void set_complexity(unsigned int new_c)#
inline unsigned int get_complexity() const#
inline void set_depth(unsigned int new_d)#
inline unsigned int get_depth() const#
inline void set_dcounter(unsigned int d)#
inline unsigned int get_dcounter() const#
inline void set_rank(unsigned r)#
inline size_t get_rank() const#
inline void set_crowding_dist(float cd)#
inline float get_crowding_dist() const#
inline Fitness(const vector<float> &w = {})#
inline size_t hash() const#
inline void set_weights(vector<float> &w)#
inline vector<float> get_weights() const#
inline vector<float> get_values() const#
inline vector<float> get_wvalues() const#
inline void set_values(vector<float> &v)#
inline void clearValues()#
inline bool valid() const#
inline bool operator==(const Fitness &other) const#
inline bool operator!=(const Fitness &other) const#
inline bool operator<(const Fitness &other) const#
inline bool operator>(const Fitness &other) const#
inline bool operator<=(const Fitness &other) const#
inline bool operator>=(const Fitness &other) const#
inline std::string toString() const#
inline std::string repr() const#
int dominates(const Fitness &b) const#

set obj vector given a string of objective names

Public Members

float loss#

aggregate loss score

float loss_v#

aggregate validation loss score

unsigned int complexity#
unsigned int size#
unsigned int depth#
unsigned int dcounter#

number of individuals this dominates

vector<unsigned int> dominated#

individual indices this dominates

unsigned int rank#

pareto front rank

float crowding_dist#

crowding distance on the Pareto front

vector<float> values#
vector<float> weights#
vector<float> wvalues#