21 for (
unsigned i = 0; i<indices.size(); ++i)
28 "Evaluation::update_fitness - attempted to update fitness of a nullptr. "
29 "This suggests population integrity was damaged by another manipulation method."));
40 ind.
error = MAX_FLT*VectorXf::Ones(data.
y.size());
50 assign_fit(ind, data, params, validation, validation_data);
56template<ProgramType T>
67 float f =
S.score(ind, train, errors, params);
71 if (validation_data !=
nullptr) {
73 f_v =
S.score(ind, *validation_data, val_errors, params);
81 f_v =
S.score(ind, validation, val_errors, params);
88 if (std::isnan(f) || std::isinf(f))
89 f = error_weight > 0 ? -MAX_FLT : MAX_FLT;
90 if (std::isnan(f_v) || std::isinf(f_v))
91 f_v = error_weight > 0 ? -MAX_FLT : MAX_FLT;
106 vector<float> values;
114 if (n.compare(params.
scorer)==0)
115 values.push_back(val ? f_v : f);
116 else if (n.compare(
"complexity")==0)
118 else if (n.compare(
"linear_complexity")==0)
120 else if (n.compare(
"size")==0)
122 else if (n.compare(
"depth")==0)
holds variable type data.
Dataset get_validation_data() const
ArrayXf y
length N array, the target label
Dataset get_training_data() const
Class for evaluating the fitness of individuals in a population.
void assign_fit(Individual< T > &ind, const Dataset &data, const Parameters ¶ms, bool val=false, Dataset *validation_data=nullptr)
Assign fitness to an individual.
void update_fitness(Population< T > &pop, int island, const Dataset &data, const Parameters ¶ms, bool fit=true, bool validation=true, bool force_fit=false, Dataset *validation_data=nullptr)
Update the fitness of individuals in a population.
size_t n_evaluations
number of calls to assign_fit (each one scores an individual on the training partition and,...
static std::map< std::string, float > weightsMap
set parent ids using id values
unsigned int get_complexity() const
unsigned int get_size() const
VectorXf error
training error (used in lexicase selectors)
Fitness fitness
aggregate fitness score
vector< string > get_objectives() const
void set_objectives(vector< string > objs)
unsigned int get_depth() const
unsigned int get_linear_complexity() const
Program< T > program
executable data structure
bool get_is_fitted() const
vector< size_t > get_island_indexes(int island)
vector< std::shared_ptr< Individual< T > > > individuals
#define HANDLE_ERROR_THROW(err)
< nsga2 selection operator for getting the front
Namespace containing scoring functions for evaluation metrics.
void set_linear_complexity(unsigned int new_lc)
void set_complexity(unsigned int new_c)
void set_loss_v(float f_v)
void set_depth(unsigned int new_d)
void set_values(vector< float > &v)
void set_size(unsigned int new_s)
vector< string > get_objectives() const
vector< float > class_weights
weights for each class
string scorer
actual loss function used, determined by error
Program< PType > & fit(const Dataset &d)