TensorTonicTensorTonic
Problems
Study PlansProjectsNewInterviewPricingFeedback
Problems
Loading...
1 / 1

Feature Store Lookup

MLOps
Easy

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.

Loading visualization...

Examples

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}]

Hint 1

Use feature_store.get(request["user_id"], defaults) for the offline lookup.

Hint 2

Create each result with {**offline, **request["online_features"]}.

Requirements

  • Look up offline features using each request's user_id
  • Use defaults when the user is absent
  • Merge offline and online features without changing the input dictionaries
  • Preserve request order

Constraints

  • 1 <= len(requests) <= 10000
  • User IDs are strings
  • Feature values are numeric
  • Offline and online feature keys do not overlap
Try Similar Problems
Etl DeduplicationEtl Schema ValidationModel Versioning BasicsTrain Serving SkewMonitoring Metrics Selection

Sign in to take notes on this problem

Case 1
Case 2

Accepts: any

Accepts: array

Accepts: any

You must run your code first.
PrevNext

Feature Store Lookup

MLOps
Easy

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.

Loading visualization...

Examples

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}]

Hint 1

Use feature_store.get(request["user_id"], defaults) for the offline lookup.

Hint 2

Create each result with {**offline, **request["online_features"]}.

Requirements

  • Look up offline features using each request's user_id
  • Use defaults when the user is absent
  • Merge offline and online features without changing the input dictionaries
  • Preserve request order

Constraints

  • 1 <= len(requests) <= 10000
  • User IDs are strings
  • Feature values are numeric
  • Offline and online feature keys do not overlap
Try Similar Problems
Etl DeduplicationEtl Schema ValidationModel Versioning BasicsTrain Serving SkewMonitoring Metrics Selection

Sign in to take notes on this problem

Case 1
Case 2

Accepts: any

Accepts: array

Accepts: any

You must run your code first.