Why models degrade in production in MLOps - Performance Analysis
We want to understand how the time it takes to detect and handle model degradation grows as data and usage increase.
How does the effort to keep a model accurate change when it faces more real-world data?
Analyze the time complexity of the following monitoring process.
for batch in incoming_data:
predictions = model.predict(batch)
actuals = get_actuals(batch)
error = calculate_error(predictions, actuals)
log_error(error)
if error > threshold:
alert_team()
This code checks model predictions against actual results in batches to detect degradation.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Looping over each batch of incoming data to predict and calculate error.
- How many times: Once per batch, repeating as new data arrives continuously.
As the number of data batches grows, the number of prediction and error calculations grows linearly.
| Input Size (n batches) | Approx. Operations |
|---|---|
| 10 | 10 prediction and error checks |
| 100 | 100 prediction and error checks |
| 1000 | 1000 prediction and error checks |
Pattern observation: The work grows directly with the number of batches processed.
Time Complexity: O(n)
This means the time to monitor model degradation grows in direct proportion to the amount of data processed.
[X] Wrong: "Model degradation detection time stays the same no matter how much data comes in."
[OK] Correct: Each new batch requires prediction and error calculation, so more data means more work.
Understanding how monitoring scales with data helps you explain real-world challenges in keeping models reliable over time.
"What if we batch data differently, using larger batches less often? How would the time complexity change?"