featuretools:如何正确生成回归任务的功能

时间:2018-04-02 07:23:53

标签: featuretools

我想尝试使用featuretools,但我需要一个提示,我如何使用我的数据集。我在pandas数据框中有数据,这是一个回归问题。

以下是我的数据集示例: enter image description here

我尝试了什么:

import featuretools as ft
es = ft.EntitySet(id = 'train_X')
es = es.entity_from_dataframe(entity_id="train_X",
                                  dataframe=X,
                                  index="Index",
                        variable_types={
 "Market": ft.variable_types.Categorical,
 "Stock": ft.variable_types.Categorical,}
                                 )

feature_matrix_customers, features_defs = ft.dfs(entities=es,
                                           target_entity="y")

出了错误:

 KeyError: 'Entity 0 does not exist in train_X').

2 个答案:

答案 0 :(得分:3)

这里的问题可能是你试图直接使用pandas数据帧作为输入,而不是将数据加载到EntitySet中。您应该创建一个EntitySet并为其构建功能。您还可以使用EntitySet.enormalize_entity(...)EntitySet一起创建其他实体以辅助功能工程。

作为注释:您可能希望使用此数据类型来使用cutoff_times,这样您就可以指定哪些数据可以用于生成要素,哪些数据不能用于生成要素。

答案 1 :(得分:0)

尝试一下。

feature_matrix_customers, features_defs = ft.dfs(entityset=es, entities=es, target_entity="train_X")