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:
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.
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]
Initialize last_retrain_day = -config["cooldown"] so the first trigger can run.
Combine the three triggers with or, then combine cooldown and budget checks with and.
Sign in to take notes on this problem
Accepts: array
Accepts: any
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:
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.
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]
Initialize last_retrain_day = -config["cooldown"] so the first trigger can run.
Combine the three triggers with or, then combine cooldown and budget checks with and.
Sign in to take notes on this problem
Accepts: array
Accepts: any