无法在 featuretools 实体集中添加关系

Posted

技术标签:

【中文标题】无法在 featuretools 实体集中添加关系【英文标题】:Unable to add relationship in featuretools entity set 【发布时间】:2021-12-05 07:23:24 【问题描述】:

新功能工具,在创建实体时遇到此错误

Unable to add relationship because child column 'order_id' in 'orders' is also its index

我怀疑功能工具需要一对多关系,有没有办法指定一对一关系?

【问题讨论】:

【参考方案1】:

是的,Featuretools 通常期望 EntitySet 中的表之间存在一对多关系,这就是为什么子列不能成为其表的索引的原因。

没有办法在关系创建中覆盖它,但您可以采取措施在子数据框中使用不同的索引列,允许 order_id 成为关系的子列。

您可以通过将make_index=True 设置为prejoin_foodorder 中的新索引列,并将索引设置为在将表添加到EntitySet 时不在DataFrame 中的某个列名。这将在 DataFrame 中创建一个新的整数列,其范围从 0 到数据帧的长度。然后该列将用作 DataFrame 的索引,而将 order_id 用作关系的子列。

es = EntitySet()
... add any other dataframes to the EntitySet ...
es.add_dataframe('prejoin_foodorder', index='new_index', make_index=True, ...)
es.add_relationship(parent_dataframe_name='orders', 
                    parent_column_name='id', 
                    child_dataframe_name='prejoin_foodorder', 
                    child_column_name='order_id')

【讨论】:

只是想知道是什么阻止了功能工具引入一对一关系? 刚刚意识到如果必须维护一对一的关系,那么所有数据都可以驻留在单个数据帧中

以上是关于无法在 featuretools 实体集中添加关系的主要内容,如果未能解决你的问题,请参考以下文章

featuretools入门

使用 FeatureTools 到带有时间戳的 normalize_entity 时无法转换列

无法在实体之间创建一对一关系

添加到托管对象有序集中

csharp 无法确定X关系的主要结束。多个添加的实体可以具有相同的主键。

自动特征工程工具包