Feat C++ API
A feature engineering automation tool
variation.h
Go to the documentation of this file.
1 /* FEAT
2 copyright 2017 William La Cava
3 license: GNU/GPL v3
4 */
5 #ifndef VARIATION_H
6 #define VARIATION_H
7 
8 #include <iostream>
9 using namespace std;
10 
11 #include "../pop/nodevector.h"
12 #include "../pop/population.h"
13 #include "../params.h"
14 
15 namespace FT{
16 
22  namespace Vary{
23 
24  //struct Individual; // forward declarations
25  //struct Parameters;
26  //struct Population;
27  //Rnd r;
29 
32  class Variation
33  {
38  public:
39 
41  Variation(float cr);
42 
43  Variation() = default;
44 
46  void set_cross_rate(float cr);
47 
49  float get_cross_rate();
50 
52  ~Variation();
53 
55  void vary(Population& pop, const vector<size_t>& parents,
56  const Parameters& params, const Data& d);
57 
58  void delete_mutate(Individual& child,
59  const Parameters& params);
60  void delete_dimension_mutate(Individual& child,
61  const Parameters& params);
62  bool correlation_delete_mutate(Individual& child,
63  MatrixXf Phi, const Parameters& params, const Data& d);
64  private:
65 
67  bool cross(const Individual& mom, const Individual& dad,
68  Individual& child, const Parameters& params,
69  const Data& d);
70 
72  bool residual_cross(const Individual& mom, const Individual& dad,
73  Individual& child, const Parameters& params,
74  const Data& d);
75 
77  bool stagewise_cross(const Individual& mom, const Individual& dad,
78  Individual& child, const Parameters& params,
79  const Data& d);
80 
82  bool mutate(const Individual& mom, Individual& child,
83  const Parameters& params, const Data& d);
84  void point_mutate(Individual& child, const Parameters& params);
85  void insert_mutate(Individual& child, const Parameters& params);
86 
88  void splice_programs(NodeVector& vnew,
89  const NodeVector& v1, size_t i1, size_t j1,
90  const NodeVector& v2, size_t i2, size_t j2);
92  void print_cross(const Individual&,size_t,size_t,
93  const Individual&, size_t, size_t, Individual&,
94  bool after=true);
95 
96  float cross_rate;
97  };
98 
99  std::unique_ptr<Node> random_node(const NodeVector & v);
100  }
101 }
102 #endif
data holding X, y, and Z data
Definition: data.h:42
individual programs in the population
Definition: individual.h:31
float cross_rate
fraction of crossover in total variation
Definition: variation.h:96
T pop(vector< T > *v)
Definition: auto_backprop.h:49
std::unique_ptr< Node > random_node(const NodeVector &v)
Definition: variation.cc:28
main Feat namespace
Definition: data.cc:13
holds the hyperparameters for Feat.
Definition: params.h:25
an extension of a vector of unique pointers to nodes
Definition: nodevector.h:23
Defines a population of programs and functions for constructing them.
Definition: population.h:28