Feat C++ API
A feature engineering automation tool
n_count.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_count.h"
6 
7 namespace FT{
8 
9 
10  namespace Pop{
11  namespace Op{
12 
14  {
15  name = "count";
16  otype = 'f';
17  arity['z'] = 1;
18  complexity = 1;
19  }
20 
21  #ifndef USE_CUDA
23  void NodeCount::evaluate(const Data& data, State& state)
24  {
25  ArrayXf tmp(state.z.top().first.size());
26  int x;
27 
28  for(x = 0; x < state.z.top().first.size(); x++)
29  tmp(x) = limited(state.z.top().first[x]).cols();
30 
31  state.z.pop();
32 
33  state.push<float>(tmp);
34 
35  }
36  #else
37  void NodeCount::evaluate(const Data& data, State& state)
38  {
39 
40  ArrayXf tmp(state.z.top().first.size());
41  int x;
42 
43  for(x = 0; x < state.z.top().first.size(); x++)
44  tmp(x) = limited(state.z.top().first[x]).cols();
45 
46  state.z.pop();
47 
48  GPU_Variable(state.dev_f, tmp.data(), state.idx[otype], state.N);
49 
50  }
51  #endif
52 
55  {
56  state.push<float>("count(" + state.zs.pop() + ")");
57  }
58 
59  NodeCount*NodeCount::clone_impl() const { return new NodeCount(*this); }
60 
61  NodeCount* NodeCount::rnd_clone_impl() const { return new NodeCount(); }
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
void evaluate(const Data &data, State &state)
Evaluates the node and updates the state states.
Definition: n_count.cc:23
void eval_eqn(State &state)
Evaluates the node symbolically.
Definition: n_count.cc:54
NodeCount * clone_impl() const override
Definition: n_count.cc:59
NodeCount * rnd_clone_impl() const override
Definition: n_count.cc:61
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)
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