假设我有两个数据集(对应于我的实体集中的两个实体):
第一个:客户(cust_id,name,birthdate,customer_since)
第二个:预订(booking_id,service,chargeamount,booking_date)
现在我想创建一个包含从 all customers (no matter since when they are customer) but only bookings from the last two years 构建的功能的数据集 .
我如何使用“last_time_index”?我可以只将“last_time_index”设置为一个实体吗?在这种情况下,仅适用于预订实体,因为我想要所有客户,但不是所有预订 .
如果使用此代码创建功能:
feature_matrix, features = ft.dfs(entityset=es,
target_entity="customers",
cutoff_time= pd.to_datetime('30/05/2018'),
training_window = ft.Timedelta(2*365,"d"),
agg_primitives=["count"],
trans_primitives=["time_since","year"],
cutoff_time_in_index = True)
1 回答
实体的
time_index
指定实例第一次有效使用 . 这样,您在设置时间索引时所做的选择可能会影响最终结果 . 根据您设置time_index
的方式,可以使用ft.dfs
与您的示例中的设置完全匹配,以获得所需的输出 . 这是一个类似于您描述的数据的玩具示例:在过去的四年里,我们每年举办一次
bookings_df
活动 . 数据框如下所示:请注意,我们有 not 为
customers
设置时间索引,这意味着所有客户数据始终有效 . 在没有training_window
参数的情况下运行DFS将返回通过添加两年的
training_window
(如您的示例所示),我们仅使用前四个预订中的两个来查看结果: