Feat C++ API
A feature engineering automation tool
n_skew.cc
Go to the documentation of this file.
1 /* FEAT
2 copyright 2017 William La Cava
3 license: GNU/GPL v3
4 */
5 
6 #include "n_skew.h"
7 #include "../../../util/utils.h"
8 
9 namespace FT{
10 
11  namespace Pop{
12  namespace Op{
14  {
15  name = "skew";
16  otype = 'f';
17  arity['z'] = 1;
18  complexity = 3;
19  }
20 
21  #ifndef USE_CUDA
23  void NodeSkew::evaluate(const Data& data, State& state)
24  {
25  ArrayXf tmp(state.z.top().first.size());
26 
27  int x;
28 
29  for(x = 0; x < state.z.top().first.size(); x++)
30  tmp(x) = skew(limited(state.z.top().first[x]));
31 
32  state.z.pop();
33 
34  state.push<float>(tmp);
35 
36  }
37  #else
38  void NodeSkew::evaluate(const Data& data, State& state)
39  {
40 
41  ArrayXf tmp(state.z.top().first.size());
42 
43  int x;
44 
45  for(x = 0; x < state.z.top().first.size(); x++)
46  tmp(x) = skew(limited(state.z.top().first[x]));
47 
48  state.z.pop();
49 
50  GPU_Variable(state.dev_f, tmp.data(), state.idx[otype], state.N);
51 
52 
53  }
54  #endif
55 
58  {
59  state.push<float>("skew(" + state.zs.pop() + ")");
60  }
61 
62  NodeSkew* NodeSkew::clone_impl() const { return new NodeSkew(*this); }
63 
64  NodeSkew* NodeSkew::rnd_clone_impl() const { return new NodeSkew(); }
65  }
66  }
67 }
data holding X, y, and Z data
Definition: data.h:42
type pop()
returns true or false depending on stack is empty or not
Definition: state.h:55
type & top()
returns element at particular location in stack
Definition: state.h:69
NodeSkew * rnd_clone_impl() const override
Definition: n_skew.cc:64
void evaluate(const Data &data, State &state)
Evaluates the node and updates the state states.
Definition: n_skew.cc:23
void eval_eqn(State &state)
Evaluates the node symbolically.
Definition: n_skew.cc:57
NodeSkew * clone_impl() const override
Definition: n_skew.cc:62
string name
node type
Definition: node.h:56
std::map< char, unsigned int > arity
arity of the operator
Definition: node.h:59
ArrayXf limited(ArrayXf x)
limits node output to be between MIN_FLT and MAX_FLT
Definition: node.cc:37
char otype
output type
Definition: node.h:58
int complexity
complexity of node
Definition: node.h:60
void GPU_Variable(float *dev_x, float *host_x, size_t idx, size_t N)
float skew(const ArrayXf &v)
calculate skew
Definition: utils.cc:141
main Feat namespace
Definition: data.cc:13
contains various types of State actually used by feat
Definition: state.h:102
Stack< string > zs
longitudinal node string stack
Definition: state.h:110
Stack< std::pair< vector< ArrayXf >, vector< ArrayXf > > > z
longitudinal node stack
Definition: state.h:106
void push(Eigen::Array< T, Eigen::Dynamic, 1 > value)
Definition: state.h:123