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']
推荐阅读
- ruby-on-rails - 如何将 NOT NULL 约束添加到新记录?
- math - 我正在尝试用 J 中的文件做一些基本的数学运算
- javascript - 为什么我的新 Google Maps API 密钥不起作用?
- javascript - TypeError:firestore.collection 不是函数(React / Redux / Firestore)
- php - 有没有办法显示与另一个表的主键相关的外键数据?
- javascript - 如何添加多行以及如何使用 c# 替换 spire Doc 中的值?
- python - 根据列表中的最小值获取键值对
- oracle - sql plus 调用存储过程后停止响应
- c++ - 计算数组每个元素的除数
- c++ - const std::shared_ptr& const 正确性