forked from hpcc-systems/ML_Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Generate.ecl
22 lines (20 loc) · 811 Bytes
/
Generate.ecl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
IMPORT $ AS ML_Core;
IMPORT ML_Core.Types;
/*
This module exists to turn one column into new columns
*/
EXPORT Generate := MODULE
EXPORT tp_Method := ENUM(UNSIGNED1, X0=0, LogX, X, XLogX, XX, XXLogX, XXX, XXXLog);
EXPORT MethodName(tp_Method x) := CHOOSE(x, 'LogX','X','XLogX','XX','XXLogX','XXX',
'XXXLogX','X0');
/*
This Attribute generates maxN columns by applying the tp_Methods to the seed column
*/
Types.NumericField mn(Types.NumericField le,UNSIGNED c) := TRANSFORM
SELF.number := c;
SELF.value := IF ( c & 1 = 1, LOG(le.value), 1 ) * POWER(le.value,(c-1));
SELF := le;
END;
EXPORT ToPoly(DATASET(Types.NumericField) seedCol, UNSIGNED maxN=6) :=
NORMALIZE(seedCol,MIN(maxN,6),mn(LEFT,COUNTER));
End;