Featuretools支持已经处理多个截止时间https://docs.featuretools.com/automated_feature_engineering/handling_time.html
In [20]: temporal_cutoffs = ft.make_temporal_cutoffs(cutoffs['customer_id'],
....: cutoffs['cutoff_time'],
....: window_size='3d',
....: num_windows=2)
....:
In [21]: temporal_cutoffs
Out[21]:
time instance_id
0 2011-12-12 13458
1 2011-12-15 13458
2 2012-10-02 13602
3 2012-10-05 13602
4 2012-01-22 15222
5 2012-01-25 15222
In [22]: entityset = ft.demo.load_retail()
In [23]: feature_tensor, feature_defs = ft.dfs(entityset=entityset,
....: target_entity='customers',
....: cutoff_time=temporal_cutoffs,
....: cutoff_time_in_index=True,
....: max_features=4)
....:
In [24]: feature_tensor
Out[24]:
MAX(order_products.total) MIN(order_products.unit_price) STD(order_products.quantity) COUNT(order_products)
customer_id time
13458.0 2011-12-12 201.960 0.3135 10.053804 394
2011-12-15 201.960 0.3135 10.053804 394
15222.0 2012-01-22 272.250 1.1880 26.832816 5
2012-01-25 272.250 1.1880 26.832816 5
13602.0 2012-10-02 49.896 1.0395 8.732068 23
2012-10-05 49.896 1.0395 8.732068 23
但正如您看到的,对于一个ID,多个时间点,将生成pandas多索引。如何(也许通过支点?)我能得到所有最小值/最大值/。。。生成的列前缀为last_x_days_MIN/MAX/。。。所以每个截止窗口都有附加功能?在
您可以通过使用不同的
training_windows
对ft.calculate_feature_matrix
进行两次调用,然后将生成的特征矩阵连接在一起。例如上面的代码返回这个DataFrame,其中我们使用过去60天和30天的数据来计算相同的特性。在
^{pr2}$注意:这个例子运行在Featuretools(v0.3.1)的最新版本上,我们在其中更新了demo retail数据集,将可解释的名称作为客户id。在
相关问题 更多 >
编程相关推荐