【问题标题】:Unable to create time-based features in a dataset which has other numerical and categorical variable无法在具有其他数值和分类变量的数据集中创建基于时间的特征
【发布时间】:2019-08-25 01:54:58
【问题描述】:

我希望特征工具根据我在实体集中声明的时间索引和截止时间来创建特征。

我有一个包含时间变量以及数值和分类变量的数据集。有一个ITEMID列,每个ITEMID有2到12行数据。

具有开始日期和交易日期等列,各种数字和分类列。给定 ITEMID 的所有行的开始日期相同,而每行的交易日期不同。

这是实体集的代码

# creating and entity set 
entity_set = ft.EntitySet(id = 'rem_dur')

# adding a dataframe 
entity_set.entity_from_dataframe(entity_id = 'enh', dataframe = dataset, index = 'unique_id'
,,variable_types = {'Start_Date': ft.variable_types.DatetimeTimeIndex})) 

#unique_id is just row number from 1 to number of rows in dataset


entity_set.normalize_entity(base_entity_id='enh', new_entity_id= 'categorical_vars', index = 'ITEMID', 
                             additional_variables = ['cat_var_1', 'cat_var_2'])

###cutoff date 
cutoff_df = dataset[["unique_id", "trans_date"]]
cutoff_df["trans_date"] = pd.to_datetime(cutoff_df["trans_date"])

##feature engg
feature_matrix_2, feature_names_2 = ft.dfs(entityset=entity_set
                                       ,target_entity = 'enh'
                                       ,max_depth = 2
                                       ,verbose = 1 
                                       ,ignore_entities = ['categorical_vars']
                                       ,ignore_variables =ignore_features_dict
                                       ,dask_kwargs={'cluster': cluster}
                                       ,cutoff_time=cutoff_df
                                      ,cutoff_time_in_index=False
                                       )

It's unable to generate any time series features. It's returning just all the features except the ones which are ignored.

【问题讨论】:

    标签: python time-series featuretools


    【解决方案1】:

    创建实体时,需要使用time_index参数指明时间索引,而不是指定变量类型。

    应该是这样的

    entity_set.entity_from_dataframe(entity_id='enh',
                                     dataframe=dataset,
                                     index='unique_id',
                                     time_index="Start_Date") 
    

    【讨论】:

    • 仍然没有使用开始日期和 cutoff_df 创建任何功能。我得到了这 4 个功能。DAY(Start_Date)>, , , ]
    • 我不确定我是否理解问题所在。 cutoff_df 不会更改特征定义,只会更改您在计算特征时获得的值。如果您获得了上面列出的那些功能,则意味着 Featuretools 正在使用开始日期制作功能。如果您可以提供可运行的代码来显示您获得的输出与预期的输出,我们可能会提供更好的帮助。
    猜你喜欢
    • 1970-01-01
    • 2020-04-20
    • 2021-02-09
    • 1970-01-01
    • 1970-01-01
    • 2018-09-25
    • 1970-01-01
    • 2016-11-15
    • 1970-01-01
    相关资源
    最近更新 更多