了解 featuretools 中的 PercentTrue 基元输出
Understanding the PercentTrue primitive output in featuretools
我一直在玩 predict-appointment-noshow notebook tutorial,我对 PERCENT_TRUE
原语的输出感到困惑。
我的理解是,在特征生成之后,像 locations.PERCENT_TRUE(appointments.sms_received)
这样的列给出了 sms_received
为 True 的行的百分比,给定一个位置,它被定义为它自己的 Entity
早些时候。我希望该列对于单个位置的所有行都是相同的,因为这是它的条件,但我发现情况并非如此。有什么想法吗?
下面是该笔记本数据中的一个示例来演示:
>>> fm.loc[fm.neighborhood == 'HORTO', 'locations.PERCENT_TRUE(appointments.sms_received)'].describe()
count 144.00
mean 0.20
std 0.09
min 0.00
25% 0.20
50% 0.23
75% 0.26
max 0.31
Name: locations.PERCENT_TRUE(appointments.sms_received), dtype: float64
尽管位置仅限于 'HORTO'
,但列的范围为 0.00-0.31。这是如何计算的?
这是计算此特征矩阵时使用截止时间的结果。
在此示例中,我们在安排约会时对每个约会进行预测。因此,特征 locations.PERCENT_TRUE(appointments.sms_received)
是在截止时间给定的特定时间计算的。它正在为每个约会计算 "the percentage of appointments at this location received an an sms prior to the scheduled_time
"
为了防止未来信息泄漏到当时对该行的预测中,该构造是必要的。如果我们使用整个数据集计算 PERCENT_TRUE
,我们必然会使用来自尚未发生的约会的信息,这对预测建模无效。
如果您想在所有数据已知后进行预测,您只需删除 ft.dfs
调用的 cutoff_time
参数:
fm, features = ft.dfs(entityset=es,
target_entity='appointments',
agg_primitives=['count', 'percent_true'],
trans_primitives=['weekend', 'weekday', 'day', 'month', 'year'],
max_depth=3,
approximate='6h',
# cutoff_time=cutoff_times[20000:],
verbose=True)
现在您可以看到,当我们以特定位置为条件时,特征是相同的
fm.loc[fm.neighborhood == 'HORTO', 'locations.PERCENT_TRUE(appointments.sms_received)'].describe()
count 175.00
mean 0.32
std 0.00
min 0.32
25% 0.32
50% 0.32
75% 0.32
max 0.32
您可以在 documentation 中阅读有关 Featuretools 如何处理时间的更多信息。
我一直在玩 predict-appointment-noshow notebook tutorial,我对 PERCENT_TRUE
原语的输出感到困惑。
我的理解是,在特征生成之后,像 locations.PERCENT_TRUE(appointments.sms_received)
这样的列给出了 sms_received
为 True 的行的百分比,给定一个位置,它被定义为它自己的 Entity
早些时候。我希望该列对于单个位置的所有行都是相同的,因为这是它的条件,但我发现情况并非如此。有什么想法吗?
下面是该笔记本数据中的一个示例来演示:
>>> fm.loc[fm.neighborhood == 'HORTO', 'locations.PERCENT_TRUE(appointments.sms_received)'].describe()
count 144.00
mean 0.20
std 0.09
min 0.00
25% 0.20
50% 0.23
75% 0.26
max 0.31
Name: locations.PERCENT_TRUE(appointments.sms_received), dtype: float64
尽管位置仅限于 'HORTO'
,但列的范围为 0.00-0.31。这是如何计算的?
这是计算此特征矩阵时使用截止时间的结果。
在此示例中,我们在安排约会时对每个约会进行预测。因此,特征 locations.PERCENT_TRUE(appointments.sms_received)
是在截止时间给定的特定时间计算的。它正在为每个约会计算 "the percentage of appointments at this location received an an sms prior to the scheduled_time
"
为了防止未来信息泄漏到当时对该行的预测中,该构造是必要的。如果我们使用整个数据集计算 PERCENT_TRUE
,我们必然会使用来自尚未发生的约会的信息,这对预测建模无效。
如果您想在所有数据已知后进行预测,您只需删除 ft.dfs
调用的 cutoff_time
参数:
fm, features = ft.dfs(entityset=es,
target_entity='appointments',
agg_primitives=['count', 'percent_true'],
trans_primitives=['weekend', 'weekday', 'day', 'month', 'year'],
max_depth=3,
approximate='6h',
# cutoff_time=cutoff_times[20000:],
verbose=True)
现在您可以看到,当我们以特定位置为条件时,特征是相同的
fm.loc[fm.neighborhood == 'HORTO', 'locations.PERCENT_TRUE(appointments.sms_received)'].describe()
count 175.00
mean 0.32
std 0.00
min 0.32
25% 0.32
50% 0.32
75% 0.32
max 0.32
您可以在 documentation 中阅读有关 Featuretools 如何处理时间的更多信息。