AI & Machine Learning Fundamentals

Chapter 11
AI Solution Development and MLOps

Advance Diploma in Artificial Intelligence and Machine Learning
AI & Machine Learning Fundamentals   •   Advance Diploma

AI Solution Development and MLOps

Introduction

Developing an artificial intelligence model is only one stage in delivering an AI-enabled product. A model that performs well in a notebook may fail when exposed to real users, changing data, strict latency requirements, unreliable networks, privacy constraints, or evolving business rules. AI solution development therefore combines machine learning with software engineering, data engineering, cloud or edge computing, security, testing, monitoring, and operational governance.

MLOps—machine learning operations—is the set of practices, tools, and organizational processes used to develop, deploy, operate, monitor, and improve machine learning systems throughout their lifecycle. It extends DevOps principles to systems whose behaviour depends not only on source code, but also on data, features, model parameters, training environments, and statistical assumptions.

A production AI system is best understood as a sociotechnical system. It includes people, processes, infrastructure, data, models, interfaces, and controls. The objective is not merely to maximize predictive accuracy, but to deliver reliable, secure, explainable, maintainable, and economically useful outcomes.

Learning Objectives

By the end of this chapter, a learner should be able to:

  1. Explain the purpose, scope, and lifecycle of MLOps.
  2. Design a basic AI pipeline using APIs, cloud services, or edge platforms.
  3. Apply version control to code, data, configurations, and models.
  4. Explain containerization, automated testing, continuous integration, and continuous delivery.
  5. Use model registries and deployment strategies appropriately.
  6. Select operational metrics and distinguish data drift from concept drift.
  7. Design monitoring, retraining, rollback, security, and lifecycle controls.
  8. Evaluate the technical, ethical, legal, and managerial risks of deploying AI.

1. From Model Development to AI Product

A conventional software application is largely determined by its code. In a machine learning application, behaviour is jointly determined by code, training data, labels, feature transformations, model architecture, learned parameters, configuration, and runtime conditions. Consequently, reproducibility requires more than storing a source-code repository.

A typical AI solution contains the following layers:

LayerMain responsibilityTypical artefacts
DataAcquire, validate, transform, and store dataSchemas, datasets, feature definitions
ModelLearn or apply predictive patternsWeights, architecture, hyperparameters
ApplicationExpose predictions to users or systemsAPI, dashboard, workflow
InfrastructureProvide compute, storage, networking, and identityContainers, clusters, cloud resources
OperationsMaintain reliability and performanceMonitoring, alerts, incident records
GovernanceControl risk and accountabilityApprovals, audit logs, documentation

The distinction between offline and online work is important. Training and evaluation are generally offline activities. Inference is the process of applying a trained model to new data, either in batch or in real time. Batch inference may score thousands of records periodically, while online inference responds to a request within a specified latency target.

A useful production objective can be expressed conceptually as:

\text{Operational value} = \text{Business benefit} - (\text{compute cost} + \text{risk cost} + \text{maintenance cost})

This is a decision framework rather than a universal accounting equation. Its terms must be defined for the particular organization. For example, risk cost may include regulatory penalties, customer compensation, security exposure, or reputational damage.

2. The Machine Learning Lifecycle

An AI lifecycle is iterative rather than strictly linear:

  1. Problem definition: Specify the decision to be improved, users, constraints, and success criteria.
  2. Data acquisition: Identify sources, permissions, quality requirements, and retention rules.
  3. Data preparation: Clean, label, transform, and split data without leakage.
  4. Model development: Select algorithms, train models, tune parameters, and record experiments.
  5. Evaluation: Assess predictive, operational, fairness, robustness, and business performance.
  6. Packaging: Combine the model with its preprocessing logic and runtime dependencies.
  7. Deployment: Release the system to a controlled cloud, on-premises, or edge environment.
  8. Monitoring: Observe service health, data quality, prediction behaviour, and outcomes.
  9. Maintenance: Investigate incidents, retrain when justified, and retire obsolete models.

The lifecycle has feedback loops. Monitoring may reveal data quality problems rather than a need for retraining. A business-policy change may require a new model even when statistical performance has not deteriorated. A security incident may require immediate rollback or suspension.

A basic reference architecture

MLOps lifecycle Data + Codeversioned inputs Validatequality checks Train + Testexperiments Registryapproved versions Deploycloud or edge Monitorhealth, drift, outcomes Monitoring evidence supports controlled improvement or rollback
MLOps lifecycle from data and code through training, registry, deployment, monitoring and retraining
Figure: MLOps lifecycle from data and code through training, registry, deployment, monitoring and retraining

Figure: A simplified MLOps lifecycle with monitoring feedback.

3. APIs, Cloud, and Edge Deployment

An API is a defined interface through which one software component requests a service from another. A prediction API commonly receives structured input and returns a prediction, confidence or probability, model version, and a request identifier. The interface should specify data types, required fields, acceptable ranges, error responses, authentication, and latency expectations.

A typical prediction request should not expose internal implementation details. It should validate input before inference, apply the same preprocessing used during training, and record sufficient metadata for diagnosis without unnecessarily storing personal information.

Cloud deployment provides elastic computing, managed storage, identity services, orchestration, and monitoring. It can accelerate development, but introduces costs, dependence on providers, data-residency considerations, and shared-responsibility security obligations.

Edge deployment places inference near the data source, such as on a camera, vehicle, industrial controller, or mobile device. Benefits include lower network latency, operation during intermittent connectivity, and improved local privacy. Constraints include limited memory, energy, compute capacity, and difficulty of updating many distributed devices. Model compression, quantization, hardware acceleration, and robust update mechanisms are therefore important.

Deployment selection should consider:

  • response-time and availability requirements;
  • data sensitivity and jurisdiction;
  • connectivity and bandwidth;
  • computational cost and device capability;
  • update frequency and rollback capability;
  • observability and physical security.

4. Reproducibility and Version Control

Version control records changes and enables collaboration. In an AI project, at least five categories should be controlled:

  1. source code;
  2. datasets or immutable dataset references;
  3. feature and preprocessing definitions;
  4. model artefacts and training configurations;
  5. infrastructure and deployment configuration.

A model should be traceable to its training data version, source-code commit, dependency environment, hyperparameters, evaluation results, and approval decision. A cryptographic hash can identify an exact file or artefact, but a hash does not by itself establish that the data is valid, representative, or legally usable.

Data leakage occurs when information unavailable at prediction time enters training. Examples include using a future outcome as a feature or randomly splitting records from the same patient across training and test sets. Leakage produces an overly optimistic evaluation and is prevented through time-aware or group-aware splitting where appropriate.

A reproducibility record should include:

ItemExample question
DataWhich records and labels were used?
CodeWhich commit created the model?
EnvironmentWhich library and runtime versions were installed?
ConfigurationWhich hyperparameters and thresholds were selected?
EvaluationWhich fixed test set and metrics were used?
LineageWhich deployed endpoint uses this model?

5. Containers and Delivery Automation

A container packages an application, its dependencies, and runtime configuration into a portable unit. Containers improve consistency between development, testing, and production, although they do not eliminate security or operating-system risks. Images should be built from minimal trusted bases, scanned for vulnerabilities, signed where possible, and run with least privilege.

Continuous integration (CI) automatically builds and tests changes proposed to a shared repository. Continuous delivery (CD) automatically prepares validated artefacts for release; continuous deployment goes further by releasing them automatically when policy gates are satisfied.

A suitable pipeline may include:

  1. code formatting and static analysis;
  2. unit tests for individual functions;
  3. data-schema and data-quality tests;
  4. preprocessing consistency tests;
  5. model evaluation on a fixed validation set;
  6. fairness, robustness, and threshold checks;
  7. container vulnerability scanning;
  8. integration and API contract tests;
  9. deployment to a staging environment;
  10. approval and controlled production release.

Testing must cover more than accuracy. A model can pass a statistical test but fail because an API returns the wrong field, a feature is missing, or latency exceeds the service-level objective.

6. Model Registries and Deployment Strategies

A model registry stores model artefacts, metadata, versions, evaluation results, and lifecycle states. Common states include development, candidate, validated, approved, production, archived, and retired. Promotion should be governed by evidence rather than by the model’s numerical score alone.

Useful metadata includes intended use, prohibited use, training-data period, known limitations, input schema, output interpretation, ethical risks, responsible owner, and approval date. A model card or equivalent technical document supports transparency.

Common release strategies are:

  • Blue–green deployment: maintain two environments and switch traffic from the old environment to the new one. Rollback is rapid, but two environments may increase cost.
  • Canary deployment: send a small proportion of traffic to the new model, observe results, then expand gradually.
  • Shadow deployment: run the new model alongside the existing model without using its predictions for decisions. This tests operational behaviour safely.
  • A/B testing: compare alternatives under a defined experimental design. Randomization, interference, and ethical constraints must be considered.

A deployment should have explicit entry and exit criteria. For example, a candidate may require no critical security findings, an agreed latency percentile, acceptable subgroup performance, and a rollback plan.

7. Metrics, Monitoring, and Alerting

Monitoring operates at several levels:

Monitoring levelExamples
InfrastructureCPU, memory, disk, accelerator use
Serviceavailability, error rate, throughput, latency
Datamissingness, range violations, schema changes
Modelaccuracy, precision, recall, calibration
Distributionfeature and prediction shifts
Businesscost, conversion, loss, intervention rate
Governanceaccess events, approvals, policy violations

For binary classification, the confusion matrix contains true positives (TP), true negatives (TN), false positives (FP), and false negatives (FN). Important metrics are:

\text{Precision} = \frac{TP}{TP + FP}
\text{Recall} = \frac{TP}{TP + FN}
\text{Accuracy} = \frac{TP + TN}{TP + TN + FP + FN}

These formulas assume mutually exclusive binary outcomes and a defined evaluation sample. Precision answers, “Among predicted positives, how many were positive?” Recall answers, “Among actual positives, how many were detected?” Accuracy can be misleading when classes are highly imbalanced. Metrics should therefore be selected according to the consequences of errors.

For regression, mean absolute error is:

\text{MAE} = \frac{1}{n}\sumi=1n|yi - \hat{y}i|

Here, yi is the observed value, \hat{y}i is the prediction, and n is the number of observations. MAE has the same units as the target and is less sensitive to large errors than mean squared error.

Monitoring requires thresholds, owners, and actions. An alert without an operational response merely creates noise. Thresholds may be static, seasonal, subgroup-specific, or based on a reference distribution. Alert policies should distinguish warning conditions from incidents requiring immediate intervention.

8. Drift and Retraining

Data drift is a change in the distribution of input data. Concept drift is a change in the relationship between inputs and the target. A system can experience data drift without performance deterioration, or performance deterioration without obvious marginal data drift.

For a categorical feature, the population stability index is sometimes used as a screening measure:

\text{PSI} = \sumj=1k(Aj - Ej)\ln\left(\frac{Aj}{Ej}\right)

Here, Aj is the current proportion in bin or category j, Ej is the reference proportion, and k is the number of bins. Both proportions must be positive; zero values require a documented smoothing rule. PSI is a heuristic indicator, not proof that a model has become invalid. Its interpretation depends on binning, sample size, domain, and decision consequences.

Retraining should not be triggered solely by a drift statistic. A responsible policy considers:

  • whether drift is persistent rather than temporary;
  • whether labels are available to measure actual performance;
  • whether business conditions or policies changed;
  • whether the new data is representative and correctly labelled;
  • whether retraining improves relevant subgroup outcomes;
  • whether the new model can be tested and rolled back.

The retraining loop should be controlled. Automatically replacing a production model with every newly trained model can amplify labelling errors, adversarial manipulation, or transient anomalies. Human approval may be required for high-impact decisions.

9. Security, Privacy, and Governance

AI systems face ordinary software threats and machine-learning-specific threats. Risks include stolen credentials, insecure dependencies, data poisoning, adversarial inputs, model extraction, prompt injection in generative systems, membership inference, and unauthorized use of sensitive attributes.

Core controls include:

  • identity-based access and least privilege;
  • encryption in transit and at rest;
  • secrets stored outside source code;
  • network segmentation and private endpoints where appropriate;
  • input validation and rate limiting;
  • signed artefacts and controlled build pipelines;
  • audit logs protected from unauthorized alteration;
  • vulnerability and dependency scanning;
  • backup, disaster recovery, and rollback procedures;
  • retention limits and secure deletion.

Privacy requires purpose limitation, data minimization, lawful processing, access control, and appropriate retention. Anonymization is difficult when multiple datasets can be linked; removing names alone does not guarantee anonymity. Organizations should assess applicable privacy and AI regulations, document the lawful basis for processing, and provide suitable transparency and review mechanisms.

Fairness must be assessed in context. Different metrics—such as group error rates, calibration, or selection rates—may conflict mathematically or operationally. A technically fair-looking model can still support an unfair process if the target variable reflects historical disadvantage or if affected people lack an appeal mechanism. Governance must therefore include impact assessment, human oversight, documentation, and accountability.

10. Case Study: Illustrative Predictive Maintenance Pipeline

Background

A manufacturing company operates pumps whose unexpected failure interrupts production. The company wants to predict failures early enough to schedule maintenance. This is an illustrative case, not a report of a particular organization.

Problem

Sensor readings arrive from edge devices, while maintenance records are stored in a cloud database. The company needs low-latency local alerts, centralized model management, and a safe mechanism for updating models.

Analysis

The team identifies temperature, vibration, pressure, operating hours, and recent maintenance history as candidate variables. A failure label is defined as a confirmed pump fault within the next seven days. This definition is important: an ambiguous or inconsistently recorded label would make performance comparisons unreliable.

Randomly mixing readings from the same pump across all dataset partitions could cause leakage because operating patterns are correlated within a pump. The team therefore uses a time-based split and evaluates performance on later periods. It also reports performance by pump type and operating environment.

Approach and Solution

The pipeline has five stages:

  1. Edge devices validate sensor ranges and calculate compact features.
  2. A containerized inference service produces a failure risk score locally.
  3. Confirmed events and selected telemetry are synchronized with the cloud.
  4. Cloud training jobs use versioned data, code, and configurations.
  5. A registry stores candidate models; a canary release sends the new model to a small group of pumps.

Monitoring includes sensor missingness, inference latency, alert frequency, calibration, false alarms, and failures missed. The model is not automatically retrained whenever vibration distributions change. Instead, drift creates an investigation ticket. Retraining occurs only after data quality and label availability are confirmed.

Outcome

The organization establishes a repeatable release process rather than relying on manual notebook execution. Maintenance planners receive alerts with model version and evidence fields, while engineers can roll back to the previous approved model. The system’s value is assessed through avoided downtime and maintenance efficiency, not accuracy alone.

Learning Points

The case demonstrates that an AI solution requires clear labels, leakage-resistant evaluation, deployment-aware design, versioned artefacts, monitoring, human workflow integration, and lifecycle controls. Edge inference and cloud training can coexist when their responsibilities and synchronization rules are explicit.

11. Limitations and Best Practices

MLOps does not guarantee correct predictions or eliminate organizational risk. Automation can make a flawed process operate faster. Cloud platforms can create vendor lock-in, and sophisticated observability can become expensive. Monitoring is limited when ground-truth labels arrive late or are themselves biased. Edge systems may be physically accessible to attackers. Finally, model performance can degrade because the world changes in ways that historical data cannot anticipate.

Recommended practices are:

  1. Begin with a clearly defined decision and measurable operational objective.
  2. Treat data, code, models, and infrastructure as versioned artefacts.
  3. Prevent leakage through appropriate temporal, group, or entity-based splits.
  4. Test data contracts, APIs, preprocessing, security, and model behaviour.
  5. Register models with lineage, limitations, approvals, and owners.
  6. Release progressively and maintain a tested rollback path.
  7. Monitor both technical service health and real-world outcomes.
  8. Investigate drift in context rather than treating every shift as failure.
  9. Restrict automated retraining in high-impact applications.
  10. Retire models and delete data according to documented lifecycle policies.
  11. Include security, privacy, fairness, and human review from project initiation.
  12. Record incidents and use them to improve engineering and governance.

Contemporary Developments

Current AI engineering increasingly combines MLOps with DataOps, ModelOps, and LLMOps. DataOps emphasizes reliable data pipelines; ModelOps manages models across analytical and operational environments; LLMOps adds concerns such as prompt and retrieval versioning, evaluation of generated content, token cost, grounding, and prompt-injection defence. Digital twins, confidential computing, federated learning, specialized accelerators, and policy-as-code are also influencing deployment design.

These developments do not replace foundational practices. New architectures still require reproducible inputs, controlled releases, observability, security, and accountable decision-making.

Chapter Summary

AI solution development extends beyond training a high-performing model. A production system must connect data acquisition, preprocessing, model development, APIs, infrastructure, testing, deployment, monitoring, governance, and retirement. MLOps provides the lifecycle framework for making these activities repeatable and controlled.

Version control and lineage make results reproducible. Containers and CI/CD improve delivery consistency. Registries and progressive deployment provide controlled promotion and rollback. Monitoring must cover infrastructure, service behaviour, data quality, model performance, business outcomes, and governance. Data drift and concept drift require contextual investigation, not automatic assumptions. Security, privacy, fairness, regulatory compliance, and human oversight are essential parts of responsible operation. The central professional principle is that an AI model is a continuously managed component of a larger sociotechnical system.

Key Terms

AI pipeline: A sequence of data, processing, modelling, deployment, and monitoring activities.

API: A defined interface through which software components communicate.

Batch inference: Producing predictions for a collection of records at scheduled intervals.

Canary deployment: Releasing a new model to a small proportion of traffic before wider release.

Concept drift: A change in the relationship between input variables and the target outcome.

Container: A portable package containing an application and its runtime dependencies.

Continuous integration: Automated building and testing of changes entering a shared codebase.

Continuous deployment: Automatic release of validated artefacts into production.

Data drift: A change in the distribution of input data.

Data leakage: Use of information during training that would not be available at prediction time.

Edge computing: Processing data near its source rather than exclusively in a centralized cloud.

Inference: Applying a trained model to new input data.

Model registry: A controlled repository for model artefacts, metadata, versions, and lifecycle states.

MLOps: Practices for developing, deploying, operating, monitoring, and governing machine learning systems.

Model lineage: Traceability between a deployed model and its data, code, environment, and approvals.

Monitoring: Systematic observation of technical, data, model, business, and governance indicators.

Rollback: Reverting a system to a previously approved version.

Shadow deployment: Running a new model for observation without using its outputs for decisions.

Review Questions

Short Answer Questions

  1. Why is versioning a machine learning model more complex than versioning source code alone?
  2. Distinguish batch inference from online inference.
  3. What is the purpose of a model registry?
  4. Define data drift and concept drift.
  5. State two security controls suitable for an AI deployment.

Long Answer Questions

  1. Explain the machine learning lifecycle and show how monitoring creates feedback into development and retraining.
  2. Compare cloud deployment with edge deployment for a latency-sensitive industrial application.
  3. Discuss how CI/CD and automated testing reduce operational risk in AI systems.
  4. Explain why accuracy alone is insufficient for evaluating a production model.
  5. Describe the governance controls required before promoting a candidate model to production.

Analytical / Application Questions

  1. A fraud model has high accuracy but misses most fraudulent transactions because fraud represents only 1% of all cases. Which metrics and deployment controls should be examined, and why?
  2. A deployed demand-forecasting model shows substantial input drift during a holiday period, but business outcomes remain acceptable. Should it be retrained immediately? Justify a monitoring and decision process.
  3. Design a basic MLOps architecture for a medical-device classifier that must operate during network outages. Identify the responsibilities of the edge device, cloud platform, model registry, monitoring system, and human reviewers.

Multiple Choice Questions with Answers

Question 1

Which artefact most directly supports traceability of a deployed model to its training process?

A. A model lineage record

B. A user-interface colour scheme

C. A random test request

D. A hardware inventory without software details

Correct Answer: A. A model lineage record

Question 2

What is the main purpose of a canary deployment?

A. To remove the need for testing

B. To expose a new model gradually to limited traffic

C. To train a model only on edge devices

D. To permanently replace the previous model immediately

Correct Answer: B. To expose a new model gradually to limited traffic

Question 3

Which situation is an example of data leakage?

A. Using a fixed test set for final evaluation

B. Recording the model version in an audit log

C. Using a future outcome as a feature during training

D. Validating input ranges before inference

Correct Answer: C. Using a future outcome as a feature during training

Question 4

In binary classification, recall is calculated as:

A. TP ÷ (TP + FP)

B. TP ÷ (TP + FN)

C. (TP + TN) ÷ total observations

D. FP ÷ (FP + TN)

Correct Answer: B. TP ÷ (TP + FN)

Question 5

Which statement best describes concept drift?

A. The input file has a changed column order

B. The relationship between inputs and the target has changed

C. The container image has been compressed

D. The model registry has gained a new user

Correct Answer: B. The relationship between inputs and the target has changed

Question 6

Which deployment approach runs a new model without using its predictions for operational decisions?

A. Shadow deployment

B. Blue–green deployment

C. Immediate replacement

D. Manual labelling

Correct Answer: A. Shadow deployment

Question 7

Why can accuracy be misleading for a highly imbalanced classification problem?

A. Accuracy cannot be calculated for binary data

B. A model can achieve high accuracy by mostly predicting the majority class

C. Accuracy always measures latency instead of predictions

D. Accuracy is only used for regression

Correct Answer: B. A model can achieve high accuracy by mostly predicting the majority class

Question 8

Which practice is most appropriate for protecting deployment credentials?

A. Embedding them directly in source code

B. Publishing them in container documentation

C. Storing them in a managed secrets system

D. Sending them in every prediction response

Correct Answer: C. Storing them in a managed secrets system

Question 9

What is the primary role of a model registry?

A. To replace all data-quality checks

B. To store and govern model versions and associated metadata

C. To provide physical cooling for edge devices

D. To guarantee that every model is unbiased

Correct Answer: B. To store and govern model versions and associated metadata

Question 10

Why should drift detection not automatically trigger production replacement in every case?

A. Drift statistics are always mathematically invalid

B. A temporary or harmless distribution change may not require retraining

C. Production systems cannot be monitored

D. Retraining never changes model behaviour

Correct Answer: B. A temporary or harmless distribution change may not require retraining

AI & Machine Learning Fundamentals
Chapter 11 of 14