如何使用来自多个 features/columns 的值组合创建有趣的值
How to create interesting values using value combinations from multiple features/columns
我对 featuretools 还很陌生,正在尝试了解是否以及如何向使用多个特征生成的实体集添加有趣的值。
例如,我有一个包含两个实体的实体集:客户和交易。交易可以是借记卡或贷记卡 (c_d),并且可以发生在不同的支出类别 (tran_category) - 餐馆、服装、杂货等。
到目前为止,我能够为这些功能中的任何一个创建有趣的值,但不能从它们的组合中创建:
import featuretools as ft
x = ft.EntitySet()
x.entity_from_dataframe(entity_id = 'customers', dataframe = customer_ids, index = cust_id)
x.entity_from_dataframe(entity_id = 'transactions', dataframe = transactions, index = tran_id, time_index = 'transaction_date')
x_rel = ft.Relationship(x['parties']['cust_id'], x['transactions']['cust_id])
x.add_relationship(x_rel)
x['transactions']['d_c'].interesting_values = ['D', 'C']
x['transactions']['tran_category'].interesting_values = ['restaurants', 'clothing', 'groceries']
如何添加一个有趣的值,该值结合了 c_d 和 tran_category 的值? (即餐厅借方、杂货店贷方、服装借方等)。目标是然后使用这些有趣的值来汇总交易金额、交易之间的时间等,使用 where_primitives:
feature_matrix, feature_defs = ft.dfs(entityset = x, target_entity = 'customers', agg_primitives = list_of_agg_primitives, where_primitives = list_of_where_primitives, trans_primitives = list_of_trans_primitives, max_depth = 3)
目前无法做到这一点。
一种方法是创建一个新列 d_c__tran_category
,其中包含 d_c
和 tran_category
的所有可能组合,然后向该列添加有趣的值。
x['transactions']['d_c__tran_category'].interesting_values = ['D_restaurants', 'C_restaurants', 'D_clothing', 'C_clothing','D_groceries', 'C_groceries']
我对 featuretools 还很陌生,正在尝试了解是否以及如何向使用多个特征生成的实体集添加有趣的值。
例如,我有一个包含两个实体的实体集:客户和交易。交易可以是借记卡或贷记卡 (c_d),并且可以发生在不同的支出类别 (tran_category) - 餐馆、服装、杂货等。
到目前为止,我能够为这些功能中的任何一个创建有趣的值,但不能从它们的组合中创建:
import featuretools as ft
x = ft.EntitySet()
x.entity_from_dataframe(entity_id = 'customers', dataframe = customer_ids, index = cust_id)
x.entity_from_dataframe(entity_id = 'transactions', dataframe = transactions, index = tran_id, time_index = 'transaction_date')
x_rel = ft.Relationship(x['parties']['cust_id'], x['transactions']['cust_id])
x.add_relationship(x_rel)
x['transactions']['d_c'].interesting_values = ['D', 'C']
x['transactions']['tran_category'].interesting_values = ['restaurants', 'clothing', 'groceries']
如何添加一个有趣的值,该值结合了 c_d 和 tran_category 的值? (即餐厅借方、杂货店贷方、服装借方等)。目标是然后使用这些有趣的值来汇总交易金额、交易之间的时间等,使用 where_primitives:
feature_matrix, feature_defs = ft.dfs(entityset = x, target_entity = 'customers', agg_primitives = list_of_agg_primitives, where_primitives = list_of_where_primitives, trans_primitives = list_of_trans_primitives, max_depth = 3)
目前无法做到这一点。
一种方法是创建一个新列 d_c__tran_category
,其中包含 d_c
和 tran_category
的所有可能组合,然后向该列添加有趣的值。
x['transactions']['d_c__tran_category'].interesting_values = ['D_restaurants', 'C_restaurants', 'D_clothing', 'C_clothing','D_groceries', 'C_groceries']