TensorTonic
Problems
Retraining Trigger Design
MLOps
Hard

Choose the days on which an ML system retrains. Process daily_stats in order while tracking remaining budget, the last retraining day, and days since retraining.

A day requests retraining when at least one condition holds:

  • drift_score > drift_threshold
  • performance < performance_threshold
  • days_since_retrain >= max_staleness

The retraining occurs only when day - last_retrain_day >= cooldown and the remaining budget covers retrain_cost. Start days_since_retrain at zero, increment it before checking each day, and reset it after retraining. The initial cooldown is already satisfied. Return the retraining day numbers in chronological order.

Loading visualization...

Examples

Input: daily_stats = [{"day": 1, "drift_score": 0.1, "performance": 0.95}, {"day": 2, "drift_score": 0.3, "performance": 0.93}, {"day": 3, "drift_score": 0.6, "performance": 0.9}, {"day": 4, "drift_score": 0.2, "performance": 0.94}], config = {"drift_threshold": 0.5, "performance_threshold": 0.7, "max_staleness": 30, "cooldown": 1, "retrain_cost": 100, "budget": 500}

Output: [3]

Explanation: Only day 3 exceeds the drift threshold, and both operational constraints permit retraining.

Input: daily_stats = [{"day": 1, "drift_score": 0.1, "performance": 0.85}, {"day": 2, "drift_score": 0.15, "performance": 0.65}, {"day": 3, "drift_score": 0.1, "performance": 0.9}], config = {"drift_threshold": 0.5, "performance_threshold": 0.7, "max_staleness": 30, "cooldown": 1, "retrain_cost": 100, "budget": 500}

Output: [2]

Hint 1

Initialize last_retrain_day = -config["cooldown"] so the first trigger can run.

Hint 2

Combine the three triggers with or, then combine cooldown and budget checks with and.

Requirements

  • Evaluate all three triggers on every day
  • Enforce cooldown and remaining budget before retraining
  • Reset staleness and deduct cost after each retraining
  • Return a list of retraining day numbers

Constraints

  • Daily statistics are sorted by increasing day
  • Configuration values are positive except thresholds may be zero
  • Threshold equality alone does not trigger drift or performance retraining
Try Similar Problems
Monitoring Metrics SelectionHardShadow Deployment EvaluationMediumDetect Train-Serving SkewMediumModel VersioningEasyData Drift DetectionEasyETL Schema Validation in PythonHardETL Dependency OrchestrationHardPoint-in-Time Feature JoinMediumSimulate Continuous BatchingHardSimulate Chunked Prefill SchedulingHardImplement Dynamic Request BatchingMediumOptimize Throughput and Cost Under a Latency SLOMedium
Scratchpad

Accepts: array

Accepts: any

You must run your code first.
Retraining Trigger Design

Retraining Trigger Design

MLOps
Hard

Choose the days on which an ML system retrains. Process daily_stats in order while tracking remaining budget, the last retraining day, and days since retraining.

A day requests retraining when at least one condition holds:

  • drift_score > drift_threshold
  • performance < performance_threshold
  • days_since_retrain >= max_staleness

The retraining occurs only when day - last_retrain_day >= cooldown and the remaining budget covers retrain_cost. Start days_since_retrain at zero, increment it before checking each day, and reset it after retraining. The initial cooldown is already satisfied. Return the retraining day numbers in chronological order.

Loading visualization...

Examples

Input: daily_stats = [{"day": 1, "drift_score": 0.1, "performance": 0.95}, {"day": 2, "drift_score": 0.3, "performance": 0.93}, {"day": 3, "drift_score": 0.6, "performance": 0.9}, {"day": 4, "drift_score": 0.2, "performance": 0.94}], config = {"drift_threshold": 0.5, "performance_threshold": 0.7, "max_staleness": 30, "cooldown": 1, "retrain_cost": 100, "budget": 500}

Output: [3]

Explanation: Only day 3 exceeds the drift threshold, and both operational constraints permit retraining.

Input: daily_stats = [{"day": 1, "drift_score": 0.1, "performance": 0.85}, {"day": 2, "drift_score": 0.15, "performance": 0.65}, {"day": 3, "drift_score": 0.1, "performance": 0.9}], config = {"drift_threshold": 0.5, "performance_threshold": 0.7, "max_staleness": 30, "cooldown": 1, "retrain_cost": 100, "budget": 500}

Output: [2]

Hint 1

Initialize last_retrain_day = -config["cooldown"] so the first trigger can run.

Hint 2

Combine the three triggers with or, then combine cooldown and budget checks with and.

Requirements

  • Evaluate all three triggers on every day
  • Enforce cooldown and remaining budget before retraining
  • Reset staleness and deduct cost after each retraining
  • Return a list of retraining day numbers

Constraints

  • Daily statistics are sorted by increasing day
  • Configuration values are positive except thresholds may be zero
  • Threshold equality alone does not trigger drift or performance retraining
Try Similar Problems
Monitoring Metrics SelectionHardShadow Deployment EvaluationMediumDetect Train-Serving SkewMediumModel VersioningEasyData Drift DetectionEasyETL Schema Validation in PythonHardETL Dependency OrchestrationHardPoint-in-Time Feature JoinMediumSimulate Continuous BatchingHardSimulate Chunked Prefill SchedulingHardImplement Dynamic Request BatchingMediumOptimize Throughput and Cost Under a Latency SLOMedium
Scratchpad

Accepts: array

Accepts: any

You must run your code first.
Problems
Loading...
1 / 1