Feat C++ API
A feature engineering automation tool
FT::Pop::Individual Class Reference

individual programs in the population More...

#include <individual.h>

Collaboration diagram for FT::Pop::Individual:

Public Types

typedef Array< bool, Dynamic, Dynamic, RowMajor > ArrayXXb
 

Public Member Functions

 Individual ()
 
void initialize (const Parameters &params, bool random, int id=0)
 copy assignment More...
 
MatrixXf out (const Data &d, bool predict=false)
 calculate program output matrix Phi More...
 
MatrixXf out_trace (const Data &d, vector< Trace > &stack_trace)
 calculate program output while maintaining stack trace More...
 
MatrixXf state_to_phi (State &state)
 converts program states to output matrices More...
 
shared_ptr< CLabels > fit (const Data &d, const Parameters &params, bool &pass)
 fits an ML model to the data after transformation More...
 
shared_ptr< CLabels > fit (const Data &d, const Parameters &params)
 fits an ML model to the data after transformation More...
 
shared_ptr< CLabels > fit_tune (const Data &d, const Parameters &params, bool set_default=false)
 fits and tunes an ML model to the data after transformation More...
 
void tune (const Data &d, const Parameters &params)
 tunes an ML model to the data after transformation More...
 
shared_ptr< CLabels > predict (const Data &d)
 
VectorXf predict_vector (const Data &d)
 
ArrayXXf predict_proba (const Data &d)
 
string get_eqn ()
 return symbolic representation of program More...
 
vector< string > get_features ()
 return vectorized representation of program More...
 
string program_str () const
 return program name list More...
 
void set_rank (unsigned r)
 setting and getting from individuals vector More...
 
int size () const
 return size of program More...
 
int get_n_params ()
 get number of params in program More...
 
unsigned int get_dim ()
 grab sub-tree locations given starting point. More...
 
int check_dominance (const Individual &b) const
 check whether this dominates b. More...
 
void set_obj (const vector< string > &)
 set obj vector given a string of objective names More...
 
unsigned int set_complexity ()
 calculate program complexity and return it. More...
 
unsigned int get_complexity () const
 get the program complexity without updating it. More...
 
void clone (Individual &cpy, bool sameid=true) const
 clone this individual More...
 
Individual clone ()
 
void set_id (unsigned i)
 
void set_parents (const vector< Individual > &parents)
 set parent ids using parents
More...
 
void set_parents (const vector< int > &parents)
 set parent ids using id values More...
 
vector< float > get_p () const
 get probabilities of variation More...
 
float get_p (const size_t i, bool normalize=true) const
 get inverted weight probability for pogram location i More...
 
vector< float > get_p (const vector< size_t > &locs, bool normalize=false) const
 get probability of variation for program locations locs More...
 
void set_p (const vector< float > &weights, const float &fb, const bool softmax_norm=false)
 set probabilities More...
 
std::map< char, size_t > get_max_state_size ()
 get maximum stack size needed for evaluation. More...
 
void save (string filename)
 save individual as a json object. More...
 
void load (string filename)
 load individual from a file. More...
 

Public Attributes

NodeVector program
 executable data structure More...
 
MatrixXf Phi
 transformation output of program More...
 
VectorXf yhat
 current output More...
 
VectorXf error
 training error More...
 
shared_ptr< MLml
 ML model, trained on Phi. More...
 
float fitness
 aggregate fitness score More...
 
float fitness_v
 aggregate validation fitness score More...
 
float fairness
 aggregate fairness score More...
 
float fairness_v
 aggregate validation fairness score More...
 
vector< float > w
 weights from ML training on program output More...
 
vector< float > p
 probability of variation of subprograms More...
 
unsigned int dim
 dimensionality of individual More...
 
vector< float > obj
 objectives for use with Pareto selection More...
 
unsigned int dcounter
 number of individuals this dominates More...
 
vector< unsigned int > dominated
 individual indices this dominates More...
 
unsigned int rank
 pareto front rank More...
 
float crowd_dist
 crowding distance on the Pareto front More...
 
unsigned int complexity
 the complexity of the program.
More...
 
vector< char > dtypes
 the data types of each column of the More...
 
unsigned id
 tracking id More...
 
vector< int > parent_id
 ids of parents More...
 
string eqn
 equation form of the program More...
 

Detailed Description

individual programs in the population

Definition at line 31 of file individual.h.

Member Typedef Documentation

◆ ArrayXXb

typedef Array<bool, Dynamic, Dynamic, RowMajor> FT::Pop::Individual::ArrayXXb

Definition at line 173 of file individual.h.

Constructor & Destructor Documentation

◆ Individual()

FT::Pop::Individual::Individual ( )

Definition at line 11 of file individual.cc.

Member Function Documentation

◆ check_dominance()

int FT::Pop::Individual::check_dominance ( const Individual b) const

check whether this dominates b.

Definition at line 898 of file individual.cc.

◆ clone() [1/2]

Individual FT::Pop::Individual::clone ( )

Definition at line 71 of file individual.cc.

◆ clone() [2/2]

void FT::Pop::Individual::clone ( Individual cpy,
bool  sameid = true 
) const

clone this individual

Definition at line 82 of file individual.cc.

◆ fit() [1/2]

shared_ptr< CLabels > FT::Pop::Individual::fit ( const Data d,
const Parameters params 
)

fits an ML model to the data after transformation

Definition at line 264 of file individual.cc.

◆ fit() [2/2]

shared_ptr< CLabels > FT::Pop::Individual::fit ( const Data d,
const Parameters params,
bool &  pass 
)

fits an ML model to the data after transformation

Definition at line 234 of file individual.cc.

◆ fit_tune()

shared_ptr< CLabels > FT::Pop::Individual::fit_tune ( const Data d,
const Parameters params,
bool  set_default = false 
)

fits and tunes an ML model to the data after transformation

Definition at line 1019 of file individual.cc.

◆ get_complexity()

unsigned int FT::Pop::Individual::get_complexity ( ) const

get the program complexity without updating it.

Definition at line 109 of file individual.cc.

◆ get_dim()

unsigned int FT::Pop::Individual::get_dim ( )

grab sub-tree locations given starting point.

get program dimensionality

Output:

@return the dimensionality, i.e. number of outputs, 
of a program. the dimensionality is equal to the number of 
times the program arities are fully
satisfied. 

Definition at line 873 of file individual.cc.

◆ get_eqn()

string FT::Pop::Individual::get_eqn ( )

return symbolic representation of program

Definition at line 748 of file individual.cc.

◆ get_features()

vector< string > FT::Pop::Individual::get_features ( )

return vectorized representation of program

Definition at line 817 of file individual.cc.

◆ get_max_state_size()

std::map< char, size_t > FT::Pop::Individual::get_max_state_size ( )

get maximum stack size needed for evaluation.

Definition at line 995 of file individual.cc.

◆ get_n_params()

int FT::Pop::Individual::get_n_params ( )

get number of params in program

Definition at line 96 of file individual.cc.

◆ get_p() [1/3]

vector< float > FT::Pop::Individual::get_p ( ) const

get probabilities of variation

Definition at line 122 of file individual.cc.

◆ get_p() [2/3]

float FT::Pop::Individual::get_p ( const size_t  i,
bool  normalize = true 
) const

get inverted weight probability for pogram location i

Parameters
iindex in program
normalize(true): normalizes the probability by the size of the subprogram. Useful when the total probability over the program nodes should sum to 1.
Returns
weight associated with node

Definition at line 175 of file individual.cc.

◆ get_p() [3/3]

vector< float > FT::Pop::Individual::get_p ( const vector< size_t > &  locs,
bool  normalize = false 
) const

get probability of variation for program locations locs

Parameters
locsprogram indices to return probabilities for.
normalize(false): normalize probabilities by size of subprogram
Returns
float vector of probabilities

Definition at line 217 of file individual.cc.

◆ initialize()

void FT::Pop::Individual::initialize ( const Parameters params,
bool  random,
int  id = 0 
)

copy assignment

Definition at line 27 of file individual.cc.

◆ load()

void FT::Pop::Individual::load ( string  filename)

load individual from a file.

Definition at line 1061 of file individual.cc.

◆ out()

MatrixXf FT::Pop::Individual::out ( const Data d,
bool  predict = false 
)

calculate program output matrix Phi

Parameters
dData structure
paramsFeat parameters
predictif true, this guarantees nodes like split do not get trained
Returns
Phi: n_features x n_samples transformation

Definition at line 391 of file individual.cc.

◆ out_trace()

MatrixXf FT::Pop::Individual::out_trace ( const Data d,
vector< Trace > &  stack_trace 
)

calculate program output while maintaining stack trace

Parameters
Xn_features x n_samples data
Zlongitudinal nodes for samples
ytarget data
Feat parameters
Returns
Phi: n_features x n_samples transformation

Definition at line 544 of file individual.cc.

◆ predict()

shared_ptr< CLabels > FT::Pop::Individual::predict ( const Data d)

generates prediction on data using transformation and ML predict.

Parameters
drop_idxif specified, the phi output at drop_idx is set to zero, effectively removing its output from the transformation. used in semantic crossover.

Definition at line 271 of file individual.cc.

◆ predict_proba()

ArrayXXf FT::Pop::Individual::predict_proba ( const Data d)

Definition at line 293 of file individual.cc.

◆ predict_vector()

VectorXf FT::Pop::Individual::predict_vector ( const Data d)

Definition at line 311 of file individual.cc.

◆ program_str()

string FT::Pop::Individual::program_str ( ) const

return program name list

Definition at line 982 of file individual.cc.

◆ save()

void FT::Pop::Individual::save ( string  filename)

save individual as a json object.

Definition at line 1050 of file individual.cc.

◆ set_complexity()

unsigned int FT::Pop::Individual::set_complexity ( )

calculate program complexity and return it.

Definition at line 967 of file individual.cc.

◆ set_id()

void FT::Pop::Individual::set_id ( unsigned  i)

Definition at line 112 of file individual.cc.

◆ set_obj()

void FT::Pop::Individual::set_obj ( const vector< string > &  objectives)

set obj vector given a string of objective names

Input: objectives: vector of strings naming objectives.

Definition at line 936 of file individual.cc.

◆ set_p()

void FT::Pop::Individual::set_p ( const vector< float > &  weights,
const float &  fb,
const bool  softmax_norm = false 
)

set probabilities

Definition at line 124 of file individual.cc.

◆ set_parents() [1/2]

void FT::Pop::Individual::set_parents ( const vector< Individual > &  parents)

set parent ids using parents

Definition at line 114 of file individual.cc.

◆ set_parents() [2/2]

void FT::Pop::Individual::set_parents ( const vector< int > &  parents)
inline

set parent ids using id values

Definition at line 150 of file individual.h.

◆ set_rank()

void FT::Pop::Individual::set_rank ( unsigned  r)

setting and getting from individuals vector

set rank

Definition at line 90 of file individual.cc.

◆ size()

int FT::Pop::Individual::size ( ) const

return size of program

Definition at line 93 of file individual.cc.

◆ state_to_phi()

MatrixXf FT::Pop::Individual::state_to_phi ( State state)

converts program states to output matrices

Definition at line 316 of file individual.cc.

◆ tune()

void FT::Pop::Individual::tune ( const Data d,
const Parameters params 
)

tunes an ML model to the data after transformation

Member Data Documentation

◆ complexity

unsigned int FT::Pop::Individual::complexity

the complexity of the program.

Definition at line 50 of file individual.h.

◆ crowd_dist

float FT::Pop::Individual::crowd_dist

crowding distance on the Pareto front

Definition at line 49 of file individual.h.

◆ dcounter

unsigned int FT::Pop::Individual::dcounter

number of individuals this dominates

Definition at line 46 of file individual.h.

◆ dim

unsigned int FT::Pop::Individual::dim

dimensionality of individual

Definition at line 44 of file individual.h.

◆ dominated

vector<unsigned int> FT::Pop::Individual::dominated

individual indices this dominates

Definition at line 47 of file individual.h.

◆ dtypes

vector<char> FT::Pop::Individual::dtypes

the data types of each column of the

Definition at line 51 of file individual.h.

◆ eqn

string FT::Pop::Individual::eqn

equation form of the program

Definition at line 55 of file individual.h.

◆ error

VectorXf FT::Pop::Individual::error

training error

Definition at line 36 of file individual.h.

◆ fairness

float FT::Pop::Individual::fairness

aggregate fairness score

Definition at line 40 of file individual.h.

◆ fairness_v

float FT::Pop::Individual::fairness_v

aggregate validation fairness score

Definition at line 41 of file individual.h.

◆ fitness

float FT::Pop::Individual::fitness

aggregate fitness score

Definition at line 38 of file individual.h.

◆ fitness_v

float FT::Pop::Individual::fitness_v

aggregate validation fitness score

Definition at line 39 of file individual.h.

◆ id

unsigned FT::Pop::Individual::id

tracking id

Definition at line 53 of file individual.h.

◆ ml

shared_ptr<ML> FT::Pop::Individual::ml

ML model, trained on Phi.

Definition at line 37 of file individual.h.

◆ obj

vector<float> FT::Pop::Individual::obj

objectives for use with Pareto selection

Definition at line 45 of file individual.h.

◆ p

vector<float> FT::Pop::Individual::p

probability of variation of subprograms

Definition at line 43 of file individual.h.

◆ parent_id

vector<int> FT::Pop::Individual::parent_id

ids of parents

Definition at line 54 of file individual.h.

◆ Phi

MatrixXf FT::Pop::Individual::Phi

transformation output of program

Definition at line 34 of file individual.h.

◆ program

NodeVector FT::Pop::Individual::program

executable data structure

Definition at line 33 of file individual.h.

◆ rank

unsigned int FT::Pop::Individual::rank

pareto front rank

Definition at line 48 of file individual.h.

◆ w

vector<float> FT::Pop::Individual::w

weights from ML training on program output

Definition at line 42 of file individual.h.

◆ yhat

VectorXf FT::Pop::Individual::yhat

current output

Definition at line 35 of file individual.h.


The documentation for this class was generated from the following files: