AI & Machine Learning Master Course — 006. The Complete Machine-Learning Lifecycle
Smartyfy AI & Machine Learning Master Course
Course ID: smartyfy-ai-ml-master-200
Lesson 006: The Complete Machine-Learning Lifecycle
Prerequisite: Lesson 005. Learning outcome: Connect problem definition, data acquisition, training, evaluation, delivery, monitoring, and retirement into a practical workflow with clear evidence at each stage.
1. Understand what the model leaves out
In Lesson 005, a short script loaded data, fitted two estimators, and printed scores. A real application needs more surrounding work. Someone must define accepted inputs, collect reliable observations, decide which version to use, handle missing information, and investigate failures. The model’s prediction is only one event in that larger process.
Return to the bicycle workshop. An accurate duration model cannot help if the booking form sends hours where training used minutes. It also cannot help if staff see its estimate after they have already promised a completion time. Technical performance, data meaning, and operational timing must fit together.
The Google production-ML overview describes the surrounding components of a deployed ML system. In this lesson, we will build a small lifecycle map without introducing production infrastructure.
2. Frame the purpose and ownership
Begin with the decision, intended users, target, prediction time, and success criteria. Name the person or role responsible for accepting a release and the person who investigates problems. Ownership is important even when one learner fills every role.
For the workshop, the intended output is an advisory estimate of active repair minutes. Staff retain responsibility for scheduling. The experiment owner maintains the dataset and report. A manager reviews whether a trial is useful. These responsibilities prevent a prediction score from silently turning into an automatic customer promise.
Write down unsupported uses. A duration estimator should not be repurposed into a mechanic-performance ranking without a new problem definition and careful review. Its labels may reflect job difficulty, interruptions, or measurement differences that make such a comparison misleading.
3. Acquire and validate the data
Collect only information needed for the approved task. Record where the data came from, how it was measured, and what use is permitted. A file that is technically accessible is not automatically appropriate for every purpose. Learning exercises can use synthetic records to avoid unnecessary personal information.
Apply the data contract from Lesson 003. Check unique booking identifiers, consistent time units, required fields, duplicates introduced by joins, and feature availability at booking. Preserve the original source or an authorized reproducible snapshot so corrections can be audited.
Then decide which observations are eligible. If canceled bookings have no active duration, document their treatment. Removing them changes the population described by the experiment. The final result should refer to completed eligible bookings, rather than all accepted bookings, unless that broader claim has separate support.
4. Develop and evaluate a candidate
Design the split before fitting learned transformations. Establish a baseline using only allowed information. Keep the candidate list and search budget manageable. Evaluate development choices using validation or suitable cross-validation; reserve final testing for the chosen procedure.
Each result should answer a specific question. “Does adding booking-time task count improve held-out duration estimates?” is testable. “Can we get a nicer score?” invites uncontrolled changes and selective reporting. Record unsuccessful experiments too, because they explain why certain choices were rejected.
Before release consideration, inspect errors rather than only the average. A model with acceptable overall error might badly underestimate uncommon repair categories. Averages describe a population; operational decisions often concern particular cases. Small slices also have uncertain results, so avoid treating a handful of records as conclusive.
5. Package a prediction procedure, not just numbers
The delivered procedure needs its feature definitions, ordering, transformations, fitted model, and expected output meaning. If the model expects [task count, inspection flag], reversing the columns changes the computation while leaving the array shape valid. Schema tests should verify meaning as well as dimensions.
Preserve the model’s relationship to its training data version, code, settings, and evaluation report. Use trusted artifact handling. Some Python model-loading formats can execute code when loaded, so an unfamiliar model file should not be treated like a harmless text document. The scikit-learn persistence guide explains security and version-compatibility considerations.
A delivery check should run a few known examples through the complete input-to-output path. This catches integration errors that an isolated estimator test misses. A successful test run establishes behavior on those examples; it does not prove every possible input is safe.
6. Choose a bounded introduction
A first operational trial might show estimates to staff without changing customer promises automatically. Another option is shadow evaluation: compute predictions while the established workflow continues, then compare them with observed outcomes. Either approach still requires appropriate permission and care around stored data.
Define a fallback before relying on the new system. If required fields are missing, the system could use the existing duration rule or request human review. Make the fallback visible enough that people know which output they received. Silently replacing a failed estimate with zero would create a misleading result.
Also retain the ability to return to an earlier working version. A rollback procedure needs a known-good artifact, compatible inputs, and someone authorized to make the change. “We can retrain later” is not a substitute for handling a failure now.
7. Monitor what can actually be observed
Separate operational health from prediction quality. Operational checks include response time, missing-field rates, and failures. Quality checks compare predictions with outcomes once the labels become available. For repair duration, the outcome arrives after completion, so immediate accuracy monitoring is impossible.
Suppose a day contains 100 prediction attempts, five missing required inputs, and two additional processing failures. Ninety-three produce ordinary model predictions. That 93% completion rate describes service behavior, not accuracy. Among completed bookings with recorded labels, a separate calculation measures duration error.
Input distributions can change without necessarily damaging performance. Performance can also deteriorate without an obvious change in a single monitored input. Treat alerts as evidence to investigate, not automatic proof that retraining is the remedy. The Google monitoring guide discusses schemas, data slices, input mismatches, and live quality checks.
8. Revise or retire deliberately
If errors rise, investigate the data pipeline, measurement policy, workload, and integration before training another model. A switch from minutes to hours requires fixing the data interpretation. Training on the broken values would embed the defect.
Retire the system when its purpose disappears, maintenance costs outweigh its value, or adequate evidence no longer supports its use. Retirement includes removing obsolete outputs from the workflow, documenting the replacement, and handling retained data and artifacts under the applicable policy. A lifecycle has an end as well as a launch.

Practice: four questions with worked answers
1. A model works in a notebook but receives reversed feature columns in the booking app. Which lifecycle gap is exposed?
Answer: Packaging and integration validation failed. Preserve feature order and test the full input-to-output path. Retraining the original estimator does not resolve the swapped-column defect.
2. Of 200 requests, 12 lack inputs and three others fail. What fraction produces ordinary predictions?
Answer: 200 − 12 − 3 = 185. Divide by 200 to get 0.925, or 92.5%. This measures request completion, not correctness of those predictions.
3. Why can repair-duration accuracy not be known immediately?
Answer: The true active duration is observed after work finishes. Monitor technical behavior immediately and assess predictive error later on appropriately matched completed records.
4. An alert reports a sudden change in input values. Should retraining start automatically?
Answer: Investigate first. A changed unit, corrupted field, or new data source may require a pipeline fix. Retraining is one possible response, not the definition of monitoring success.
Knowledge check: five explained MCQs
1. Which belongs in the lifecycle? A. Only estimator fitting. B. Data validation and monitoring. C. Only selecting a model name.
Correct: B. A useful system depends on data and ongoing behavior as well as training.
2. A fallback should be defined: A. Before dependence on the new system. B. Only after every failure. C. Never.
Correct: A. Preparing a fallback reduces improvisation when outputs are unavailable or unreliable.
3. A 99% request completion rate establishes: A. 99% accuracy. B. High measured service completion. C. Zero bias.
Correct: B. Operational availability and predictive quality are distinct measurements.
4. An unfamiliar serialized model file is: A. Always harmless. B. Potentially unsafe to load. C. Necessarily a dataset.
Correct: B. Some serialization formats can execute code; provenance and loading method matter.
5. Model retirement is appropriate when: A. Its purpose no longer exists. B. Its latest training loss decreases. C. A newer model architecture becomes available.
Correct: A. A system should serve a justified purpose with sufficient value and support.
Common pitfalls and summary
Avoid treating a trained file as a complete product, ignoring delayed outcomes, confusing uptime with accuracy, or retraining through a data defect. A sound lifecycle connects decisions, data, evidence, delivery, operation, and eventual retirement. Each transition needs a clear reason and a reviewable record.