NOTICE
The upcoming release of Featuretools 1.0.0 contains several breaking changes. Users are encouraged to test this version prior to release by installing from GitHub:
pip install https://github.com/alteryx/featuretools/archive/woodwork-integration.zip
For details on migrating to the new version, refer to Transitioning to Featuretools Version 1.0. Please report any issues in the Featuretools GitHub repo or by messaging in Alteryx Open Source Slack.
featuretools.primitives.
make_agg_primitive
Returns a new aggregation primitive class. The primitive infers default values by passing in empty data.
function (function) – Function that takes in a series and applies some transformation to it.
input_types (list[Variable]) – Variable types of the inputs.
return_type (Variable) – Variable type of return.
name (str) – Name of the function. If no name is provided, the name of function will be used.
stack_on_self (bool) – Whether this primitive can be in input_types of self.
stack_on (list[PrimitiveBase]) – Whitelist of primitives that can be input_types.
stack_on_exclude (list[PrimitiveBase]) – Blacklist of primitives that cannot be input_types.
base_of (list[PrimitiveBase) – Whitelist of primitives that can have this primitive in input_types.
base_of_exclude (list[PrimitiveBase]) – Blacklist of primitives that cannot have this primitive in input_types.
description (str) – Description of primitive.
cls_attributes (dict[str -> anytype]) – Custom attributes to be added to class. Key is attribute name, value is the attribute value.
uses_calc_time (bool) – If True, the cutoff time the feature is being calculated at will be passed to the function as the keyword argument ‘time’.
default_value (Variable) – Default value when creating the primitive to avoid the inference step. If no default value if provided, the inference happen.
commutative (bool) – If True, will only make one feature per unique set of base features.
number_output_features (int) – The number of output features (columns in the matrix) associated with this feature.
Example
In [1]: from featuretools.primitives import make_agg_primitive In [2]: from featuretools.variable_types import DatetimeTimeIndex, Numeric In [3]: def time_since_last(values, time=None): ...: time_since = time - values.iloc[-1] ...: return time_since.total_seconds() ...: In [4]: TimeSinceLast = make_agg_primitive( ...: function=time_since_last, ...: input_types=[DatetimeTimeIndex], ...: return_type=Numeric, ...: description="Time since last related instance", ...: uses_calc_time=True) ...: