In the classic mock customer dataset example in featuretools, if I have to derive trans_primitives
like month, day, year
etc. of transaction_time
attribute of transactions entity
. How do I do that?
import featuretools as ft
es = ft.demo.load_mock_customer(return_entityset=True)
feature_matrix, feature_defs = ft.dfs(entityset=es, target_entity=???, agg_primitives=["count"], trans_primitives=["month"], max_depth=1)
What should be the target entity in such case?
Thanks for the question! You can get those features from the transaction time by setting the target entity to transactions
in DFS. You also want to specify which transform primitives to apply. Let me know if this helps.
feature_matrix, feature_defs = ft.dfs(
entityset=es,
target_entity='transactions',
agg_primitives=[],
trans_primitives=['day', 'month', 'year'],
max_depth=1,
)
feature_matrix.head().filter(regex='time')
DAY(transaction_time) MONTH(transaction_time) YEAR(transaction_time)
transaction_id
298 1 1 2014
2 1 1 2014
308 1 1 2014
116 1 1 2014
371 1 1 2014