Feat C++ API
A feature engineering automation tool
FT::Vary::Variation Class Reference

#include <variation.h>

Public Member Functions

 Variation (float cr)
 constructor More...
 
 Variation ()=default
 
void set_cross_rate (float cr)
 update cross rate More...
 
float get_cross_rate ()
 return current cross rate More...
 
 ~Variation ()
 destructor More...
 
void vary (Population &pop, const vector< size_t > &parents, const Parameters &params, const Data &d)
 method to handle variation of population More...
 
void delete_mutate (Individual &child, const Parameters &params)
 
void delete_dimension_mutate (Individual &child, const Parameters &params)
 
bool correlation_delete_mutate (Individual &child, MatrixXf Phi, const Parameters &params, const Data &d)
 

Private Member Functions

bool cross (const Individual &mom, const Individual &dad, Individual &child, const Parameters &params, const Data &d)
 crossover More...
 
bool residual_cross (const Individual &mom, const Individual &dad, Individual &child, const Parameters &params, const Data &d)
 residual crossover More...
 
bool stagewise_cross (const Individual &mom, const Individual &dad, Individual &child, const Parameters &params, const Data &d)
 stagewise crossover More...
 
bool mutate (const Individual &mom, Individual &child, const Parameters &params, const Data &d)
 mutation More...
 
void point_mutate (Individual &child, const Parameters &params)
 
void insert_mutate (Individual &child, const Parameters &params)
 
void splice_programs (NodeVector &vnew, const NodeVector &v1, size_t i1, size_t j1, const NodeVector &v2, size_t i2, size_t j2)
 splice two programs together More...
 
void print_cross (const Individual &, size_t, size_t, const Individual &, size_t, size_t, Individual &, bool after=true)
 debugging printout of crossover operation. More...
 

Private Attributes

float cross_rate
 fraction of crossover in total variation More...
 

Detailed Description

Definition at line 32 of file variation.h.

Constructor & Destructor Documentation

◆ Variation() [1/2]

FT::Vary::Variation::Variation ( float  cr)

constructor

methods for crossover and mutation of programs.

Definition at line 11 of file variation.cc.

◆ Variation() [2/2]

FT::Vary::Variation::Variation ( )
default

◆ ~Variation()

FT::Vary::Variation::~Variation ( )

destructor

Definition at line 26 of file variation.cc.

Member Function Documentation

◆ correlation_delete_mutate()

bool FT::Vary::Variation::correlation_delete_mutate ( Individual child,
MatrixXf  Phi,
const Parameters params,
const Data d 
)

deletion mutation. works by pruning a dimension. the dimension that is pruned matches these criteria: 1) it is in the pair of features most highly correlated. 2) it is less correlated with the dependent variable than its pair.

Parameters
childindividual to be mutated
Phithe behavior of the parent
paramsparameters
ddata
Returns
mutated child

Definition at line 465 of file variation.cc.

◆ cross()

bool FT::Vary::Variation::cross ( const Individual mom,
const Individual dad,
Individual child,
const Parameters params,
const Data d 
)
private

crossover

crossover by either subtree crossover or swapping of dimensions.

Parameters
momroot parent
dadparent from which subtree is chosen
childresult of cross
paramsparameters
Returns
child: mom with dad subtree graft

Definition at line 551 of file variation.cc.

◆ delete_dimension_mutate()

void FT::Vary::Variation::delete_dimension_mutate ( Individual child,
const Parameters params 
)

deletion mutation. works by pruning a dimension.

Parameters
childindividual to be mutated
paramsparameters
Returns
mutated child

Definition at line 437 of file variation.cc.

◆ delete_mutate()

void FT::Vary::Variation::delete_mutate ( Individual child,
const Parameters params 
)

deletion mutation. works by pruning a dimension.

Parameters
childindividual to be mutated
paramsparameters
Returns
mutated child

Definition at line 359 of file variation.cc.

◆ get_cross_rate()

float FT::Vary::Variation::get_cross_rate ( )

return current cross rate

Definition at line 20 of file variation.cc.

◆ insert_mutate()

void FT::Vary::Variation::insert_mutate ( Individual child,
const Parameters params 
)
private

insertion mutation.

Parameters
childindiviudal to be mutated
paramsparameters
Returns
modified child

Definition at line 232 of file variation.cc.

◆ mutate()

bool FT::Vary::Variation::mutate ( const Individual mom,
Individual child,
const Parameters params,
const Data d 
)
private

mutation

chooses uniformly between point, insert and delete mutation

Parameters
momparent
childoffspring produced by mutating mom
paramsparameters
Returns
true if valid child, false if not

Definition at line 114 of file variation.cc.

◆ point_mutate()

void FT::Vary::Variation::point_mutate ( Individual child,
const Parameters params 
)
private

1/n point mutation.

Parameters
childindividual to be mutated
paramsparameters
Returns
modified child

Definition at line 174 of file variation.cc.

◆ print_cross()

void FT::Vary::Variation::print_cross ( const Individual mom,
size_t  i1,
size_t  j1,
const Individual dad,
size_t  i2,
size_t  j2,
Individual child,
bool  after = true 
)
private

debugging printout of crossover operation.

Definition at line 970 of file variation.cc.

◆ residual_cross()

bool FT::Vary::Variation::residual_cross ( const Individual mom,
const Individual dad,
Individual child,
const Parameters params,
const Data d 
)
private

residual crossover

crossover by swapping in a dimension most correlated with the residual of mom.

Parameters
momroot parent
dadparent from which subtree is chosen
childresult of cross
paramsparameters
Returns
child: mom with dad subtree graft

Definition at line 645 of file variation.cc.

◆ set_cross_rate()

void FT::Vary::Variation::set_cross_rate ( float  cr)

update cross rate

Definition at line 14 of file variation.cc.

◆ splice_programs()

void FT::Vary::Variation::splice_programs ( NodeVector vnew,
const NodeVector v1,
size_t  i1,
size_t  j1,
const NodeVector v2,
size_t  i2,
size_t  j2 
)
private

splice two programs together

swap vector subsets with different sizes. constructs a vector made of v1[0:i1], v2[i2:j2], v1[i1:end].

Parameters
v1root parent
i1start of splicing segment
j1end of splicing segment
v2donating parent
i2start of donation
j2end of donation
Returns
vnew: new vector

Definition at line 925 of file variation.cc.

◆ stagewise_cross()

bool FT::Vary::Variation::stagewise_cross ( const Individual mom,
const Individual dad,
Individual child,
const Parameters params,
const Data d 
)
private

stagewise crossover

crossover by forward stagewise selection, matching mom's dimensionality.

Parameters
momroot parent
dadparent from which subtree is chosen
childresult of cross
paramsparameters
Returns
child: mom with dad subtree graft procedure: set the residual equal to target $y$. center means around zero for all $\phi$. set $\phi_A$ to be all subprograms in $\phi_{p0}$ and $\phi_{p1}$. while $|\phi_{c}| < |\phi_{p0}|$:
  • pick $\phi^*$ from $\phi_{A}$ which is most correlated with $\mathbf{r}$.
  • compute the least squares coefficient $b$ for $\phi^*$ fit to $\mathbf{r}$.
  • update $\mathbf{r} = r - b\phi^*$ $\phi_c$ = all $\phi^*$ that were chosen

Definition at line 743 of file variation.cc.

◆ vary()

void FT::Vary::Variation::vary ( Population pop,
const vector< size_t > &  parents,
const Parameters params,
const Data d 
)

method to handle variation of population

performs variation on the current population.

Parameters
popcurrent population
parentsindices of population to use for variation
paramsfeat parameters
Returns
appends params.pop_size offspring derived from parent variation

Definition at line 40 of file variation.cc.

Member Data Documentation

◆ cross_rate

float FT::Vary::Variation::cross_rate
private

fraction of crossover in total variation

Definition at line 96 of file variation.h.


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