Model approval workflows in MLOps - Time & Space Complexity
When managing machine learning models, approval workflows help decide which models are ready to use.
We want to know how the time to approve models changes as more models enter the workflow.
Analyze the time complexity of the following model approval process.
for model in model_list:
if evaluate_model(model):
approve_model(model)
else:
reject_model(model)
This code checks each model one by one, evaluates it, and then approves or rejects it.
Look for repeated actions in the code.
- Primary operation: Looping through each model in the list.
- How many times: Once for every model in the list.
As the number of models grows, the time to approve them grows too.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 evaluations and approvals/rejections |
| 100 | 100 evaluations and approvals/rejections |
| 1000 | 1000 evaluations and approvals/rejections |
Pattern observation: The work grows directly with the number of models.
Time Complexity: O(n)
This means the time to finish approval grows in a straight line as more models come in.
[X] Wrong: "Approving multiple models at once takes the same time as approving one."
[OK] Correct: Each model needs its own evaluation and decision, so more models mean more time.
Understanding how approval time grows helps you design workflows that scale well as your model collection grows.
What if we batch evaluate models instead of one by one? How would the time complexity change?