03-model-degradation-retrain-trigger built the DECISION of whether a model needs retraining, but "when do we actually retrain?" has at least three genuinely different real answers, each with a different cost/responsiveness tradeoff: retrain on a fixed calendar schedule regardless of need, retrain only when degradation is actually detected, or never really "retrain" as a discrete event at all, instead nudging the model continuously with every new labeled example.
Implement scheduled_retrain_due, triggered_retrain_due (built directly on 03-model-degradation-retrain-trigger's has_model_degraded), and online_update_step, a genuine single-example gradient descent update.
scheduled_retrain_due(days_since_last_retrain, schedule_interval_days) returns True once the interval has elapsed, regardless of any performance signal.triggered_retrain_due(current_metric, baseline_metric, tolerance) returns exactly has_model_degraded's result.online_update_step(weight, bias, x, y, learning_rate) performs one step of gradient descent on the squared error (weight*x + bias - y)^2, returning the updated (weight, bias).(weight, bias) in a direction that DECREASES that squared error (for a small enough learning rate).Open one at a time. Each gives away a little more than the last.
Scheduled and triggered retraining answer genuinely INDEPENDENT questions: a model can be well within tolerance (triggered says "no need") while still being well past its scheduled interval (scheduled says "yes, due anyway"), or vice versa.
online_update_step's gradient is exactly the same chain-rule computation linear-regression-mse-gradient's Theory built up, specialized to a single scalar x/y pair instead of a whole batch: grad_weight = 2 * x * error, grad_bias = 2 * error, where error = (weight*x + bias) - y.
No results yet
Run your code to check it against the examples, or submit to run every test.