Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update properties of cumulative transform primitives #320

Merged
merged 4 commits into from Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion featuretools/primitives/cum_transform_feature.py
Expand Up @@ -19,7 +19,7 @@ class CumFeature(TransformPrimitive):
allow_where = True
agg_feature = None
rolling_function = True
needs_all_values = True
uses_full_entity = True

# Note: Any row with a nan value in the group by feature will have a
# NaN value in the cumfeat
Expand Down
Expand Up @@ -617,6 +617,21 @@ def test_cum_sum_use_previous_and_where_absolute(es):
assert v == cvalues[i]


def test_cum_handles_uses_full_entity(es):
def check(feature):
pandas_backend = PandasBackend(es, [feature])
df_1 = pandas_backend.calculate_all_features(instance_ids=[0, 1, 2], time_last=None)
df_2 = pandas_backend.calculate_all_features(instance_ids=[2], time_last=None)

# check that the value for instance id 2 matches
assert (df_2.loc[2] == df_1.loc[2]).all()

for primitive in [CumSum, CumMean, CumMax, CumMin]:
check(primitive(es['log']['value'], es['log']['session_id']))

check(CumCount(es['log']['id'], es['log']['session_id']))


def test_cum_mean(es):
log_value_feat = es['log']['value']
cum_mean = CumMean(log_value_feat, es['log']['session_id'])
Expand Down