get_online_features 与 get_historical_features 有何区别?
先说出你的答案
定义边界、关键机制、一个反例;P8题再补容量、失败与验证。
查看完整题解
参考回答
直接回答
get_online_features 为一次在线推理查当前可用的值,传实体键,必要时传请求字段。旧版 get_historical_features 接收历史样本表,为每行按预测时点查值。
讲清原理
在 1.2 中旧历史方法已弃用,新代码用 get_features_for_events。它返回批量特征数据。默认读取已启用的离线物化数据,其他部分可按配置从源计算。
例子与易错点
代码检查实际 SDK 参数。查询“今天账户是什么等级”和补“昨天预测样本的等级”,输入结构分别是一组在线字段和一张事件表。
from inspect import signature
from tecton import FeatureService
online = signature(FeatureService.get_online_features)
history = signature(FeatureService.get_features_for_events)
assert set(online.parameters) >= {"join_keys", "request_data"}
assert set(history.parameters) >= {"events", "timestamp_key", "from_source"}
print("online: join_keys and request_data; history: events and timestamp_key")
和评分标准对照,你能独立回答到哪一步?
自评会安排下一次复习,不保存你的口述内容。
这道题,你掌握得怎么样?
掌握程度由你主动标记,阅读和收藏不会自动改变状态。