【问题标题】:featuretools: how can I apply `time_since`, `time_since_first` primitives on integer type of time index?featuretools:如何在整数类型的时间索引上应用 `time_since`、`time_since_first` 原语?
【发布时间】:2021-03-06 04:37:57
【问题描述】:

当时间索引为整数时(例如每个用户从 0 开始),运行dfs 会显示警告:

UnusedPrimitiveWarning: Some specified primitives were not used during DFS:
  agg_primitives: ['avg_time_between', 'time_since_first', 'time_since_last', 'trend']
  groupby_trans_primitives: ['cum_count', 'time_since', 'time_since_previous']
This may be caused by a using a value of max_depth that is too small, not setting interesting values, or it may indicate no compatible variable types for the primitive were found in the data.

但是,时间索引在很多情况下可以是整数(例如https://www.kaggle.com/c/riiid-test-answer-prediction/data):

  • 当 user1 开始被记录时,其第一个日志的时间戳为 0(例如,2020-01-01 13:10:10)
  • 当用户 1 的第二个日志在接下来的 100 秒后被记录时,其第二个日志的时间戳为 100。
  • 同样,当 user2 开始被记录时,其第一个记录的时间戳始终为 0(注意:2020-11-01 00:00:00,此时(
  • 正如您在此处看到的,user1 和 user2 在不同的日期和时间开始登录,但它们具有相同的时间索引。似乎他们使用相对时间作为特征。

在这种情况下,即使我在创建实体集时将timestamp 变量设置为ft.variable_types.TimeIndex(numeric_time_index),它仍然显示相同的警告并且['avg_time_between', 'time_since_first', 'time_since_last', 'trend'] 生成的功能没有出现。

我该如何处理?

【问题讨论】:

    标签: featuretools


    【解决方案1】:

    感谢您的提问。 time_sincetime_since_first 原语目前仅用于处理 DatetimeDatetimeTimeIndex 变量。要处理时间索引为数字的情况,您可以创建自定义原语来处理 NumericTimeIndex 变量。

    from featuretools.primitives import AggregationPrimitive, TransformPrimitive
    from featuretools.variable_types import NumericTimeIndex
    
    
    class TimeSinceNumeric(TransformPrimitive):
        input_types = [NumericTimeIndex]
        ...
    
    
    class TimeSinceFirstNumeric(AggregationPrimitive):
        input_types = [NumericTimeIndex]
        ...
    

    然后,您可以将自定义原语直接传递给 DFS。

    ft.dfs(
        ...
        trans_primitives=[TimeSinceNumeric],
        agg_primitives=[TimeSinceFirstNumeric],
    )
    

    【讨论】:

      猜你喜欢
      • 2019-09-04
      • 1970-01-01
      • 1970-01-01
      • 2019-11-13
      • 2019-11-06
      • 1970-01-01
      • 2021-08-11
      • 2012-02-28
      • 2019-06-14
      相关资源
      最近更新 更多