我正在尝试使用Featuretools包创建自定义转换,在该包中,我可以输入参数并更改函数的行为
例如,对于下面的自定义日志转换类,我希望添加一个base参数,这样我就可以对具有不同基础的特性进行log转换:
class Log(TransformPrimitive):
"""Computes the logarithm for a numeric column."""
name = 'log'
input_types = [Numeric]
return_type = Numeric
def get_function(self):
return np.log我该如何实现这样的原语,而且如何使用featuretools.dfs()函数来实现它呢?
发布于 2019-07-09 23:30:49
考虑类中的__init__函数。
例如,
class Log(TransformPrimitive):
"""Computes the logarithm for a numeric column."""
name = 'log'
input_types = [Numeric]
return_type = Numeric
def __init__(self, n=3):
self.n = n
def get_function(self):
return np.log
# adjust for variable base, probably using something like
# np.log(array) / np.log(self.n)我们称之为:log_base_n = Log(n=2)。
在DFS中,您可以将相应的类实例添加到原语列表中。
https://stackoverflow.com/questions/56866470
复制相似问题