/
primitive_base.py
44 lines (36 loc) · 1.52 KB
/
primitive_base.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from __future__ import absolute_import
import os
import numpy as np
from featuretools import config
class PrimitiveBase(object):
"""Base class for all primitives."""
#: (str): Name of the primitive
name = None
#: (list): Variable types of inputs
input_types = None
#: (:class:`.Variable`): variable type of return
return_type = None
#: Default value this feature returns if no data found. Defaults to np.nan
default_value = np.nan
#: (bool): True if feature needs to know what the current calculation time
# is (provided to computational backend as "time_last")
uses_calc_time = False
#: (bool): If True, allow where clauses in DFS
allow_where = False
#: (int): Maximum number of features in the largest chain proceeding
# downward from this feature's base features.
max_stack_depth = None
#: (int): Number of columns in feature matrix associated with this feature
number_output_features = 1
# whitelist of primitives can have this primitive in input_types
base_of = None
# blacklist of primitives can have this primitive in input_types
base_of_exclude = None
# (bool) If True will only make one feature per unique set of base features
commutative = False
def generate_name(self):
raise NotImplementedError("Subclass must implement")
def get_function(self):
raise NotImplementedError("Subclass must implement")
def get_filepath(self, filename):
return os.path.join(config.get("primitive_data_folder"), filename)