Feat C++ API
A feature engineering automation tool
n_kurtosis.cc
Go to the documentation of this file.
1 /* FEAT
2 copyright 2017 William La Cava
3 license: GNU/GPL v3
4 */
5 #include "n_kurtosis.h"
6 #include "../../../util/utils.h"
7 
8 namespace FT{
9 
10  namespace Pop{
11  namespace Op{
12 
14  {
15  name = "kurtosis";
16  otype = 'f';
17  arity['z'] = 1;
18  complexity = 1;
19  }
20 
21  #ifndef USE_CUDA
23  void NodeKurtosis::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) = kurtosis(limited(state.z.top().first[x]));
31 
32  state.z.pop();
33  state.push<float>(tmp);
34 
35  }
36  #else
37  void NodeKurtosis::evaluate(const Data& data, State& state)
38  {
39 
40  ArrayXf tmp(state.z.top().first.size());
41 
42  int x;
43 
44  for(x = 0; x < state.z.top().first.size(); x++)
45  tmp(x) = kurtosis(limited(state.z.top().first[x]));
46 
47  state.z.pop();
48  GPU_Variable(state.dev_f, tmp.data(), state.idx[otype], state.N);
49 
50  }
51  #endif
52 
55  {
56  state.push<float>("kurtosis(" + state.zs.pop() + ")");
57  }
58 
59  NodeKurtosis* NodeKurtosis::clone_impl() const { return new NodeKurtosis(*this); }
60 
62  }
63  }
64 }
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
NodeKurtosis * rnd_clone_impl() const override
Definition: n_kurtosis.cc:61
void evaluate(const Data &data, State &state)
Evaluates the node and updates the state states.
Definition: n_kurtosis.cc:23
NodeKurtosis * clone_impl() const override
Definition: n_kurtosis.cc:59
void eval_eqn(State &state)
Evaluates the node symbolically.
Definition: n_kurtosis.cc:54
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 kurtosis(const ArrayXf &v)
calculate kurtosis
Definition: utils.cc:153
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