At prediction time, an ML service often combines precomputed offline features with request-time online features. Given a feature store keyed by user ID, inference requests, and default offline features, build one combined feature dictionary for each request.
For a known user, use the stored offline features. For an unknown user, use defaults. Then add the request's online_features. Offline and online keys do not overlap. Preserve request order and return a list of combined dictionaries.
Input: feature_store = {"user_1": {"avg_spend": 45, "total_orders": 12}}, requests = [{"user_id": "user_1", "online_features": {"pages_viewed": 8, "session_mins": 5}}], defaults = {"avg_spend": 0, "total_orders": 0}
Output: [{"avg_spend": 45, "total_orders": 12, "pages_viewed": 8, "session_mins": 5}]
Explanation: The stored features for user_1 are combined with that request's online features.
Input: feature_store = {"user_1": {"avg_spend": 45, "total_orders": 12}}, requests = [{"user_id": "user_99", "online_features": {"session_mins": 1}}], defaults = {"avg_spend": 0, "total_orders": 0}
Output: [{"avg_spend": 0, "total_orders": 0, "session_mins": 1}]
Use feature_store.get(request["user_id"], defaults) for the offline lookup.
Create each result with {**offline, **request["online_features"]}.
Sign in to take notes on this problem
Accepts: any
Accepts: array
Accepts: any
At prediction time, an ML service often combines precomputed offline features with request-time online features. Given a feature store keyed by user ID, inference requests, and default offline features, build one combined feature dictionary for each request.
For a known user, use the stored offline features. For an unknown user, use defaults. Then add the request's online_features. Offline and online keys do not overlap. Preserve request order and return a list of combined dictionaries.
Input: feature_store = {"user_1": {"avg_spend": 45, "total_orders": 12}}, requests = [{"user_id": "user_1", "online_features": {"pages_viewed": 8, "session_mins": 5}}], defaults = {"avg_spend": 0, "total_orders": 0}
Output: [{"avg_spend": 45, "total_orders": 12, "pages_viewed": 8, "session_mins": 5}]
Explanation: The stored features for user_1 are combined with that request's online features.
Input: feature_store = {"user_1": {"avg_spend": 45, "total_orders": 12}}, requests = [{"user_id": "user_99", "online_features": {"session_mins": 1}}], defaults = {"avg_spend": 0, "total_orders": 0}
Output: [{"avg_spend": 0, "total_orders": 0, "session_mins": 1}]
Use feature_store.get(request["user_id"], defaults) for the offline lookup.
Create each result with {**offline, **request["online_features"]}.
Sign in to take notes on this problem
Accepts: any
Accepts: array
Accepts: any