Machine Learning Series: MLOps Overview
Hello Reader,
MLOps (Machine Learning Operations) is a new and emerging practice in the ML field. Under the hood MLOps includes tools, principles and best practices to support ML project lifecycle.
The practice around data and ML is a evolving rapidly and there are a plenty of buzz words and concepts often the distinction between these practices is not strictly defined and we can notice a few overlapping , I have gathered the most common : DataOps, MLOps, ModelOps, PlatformOps for AI, AIOps there are so many terms that in the industry we are start referring to as Xops. All have a common ancestor DevOps but all bring their own features.
Let's see in detail the meaning of each of the XOps terms
DataOps
Is a collaborative data management practice that aim to manage data pipelines and monitoring metadata and data quality with an accent to reusability, structured test and fast change management of ETLs the output of the process is typically in a data warehouse, data lake or a feature store. In summary DataOps is the set of processes and technologies that aims to develop and operationalize data pipelines and is focused on the data ingestion phase. As for DevOps the adoption of this practice requires a cultural change in the organization improving collaboration among the teams to accelerate pipelines deployment process.
MLOps / ModelOps
Machine Learning Operations, is a set of tool and processes that facilitate development, test, deployment, monitoring of machine learning models it leverages the CI/CD framework and derives its core principles from DevOps. ModelOps is similar to MLOps but giving more autonomy to business expert to evaluate and promote models.
PlatformOps for AI
Platform Ops for AI is a set of processes and technologies that can be used to orchestrate all different stages of an AI system. In summary the platform create a bridge between DataOps, MLOps/ ModelOps and DevOps
AIOps
Set of technologies that add the power of AI to the IT operations, it include the management of massive amount of operational data (logs and metrics) generated by IT systems which is used to generate proactive and predictive actions to improve efficiency and availability of the IT infrastructure and applications.
![]() |
| https://www.gartner.com/en/documents/4001009/demystifying-xops-from-dataops-to-modelops-and-platform- |
How big is the MLOps Market
In a research conducted by Cognilytica an AI focused research company the market of MLOps platforms is forecasted to generate 4 Billion USD as year by 2025. For Gartner By 2025 70% of enterprises will have operationalize AI architecture due to rapid maturity of AI orchestration platform and the overall revenue from Data Science and Machine Learning platform software grew by 17.5% in 2019. Now let's deep dive into MLOps
MLOps
MLOps is the younger and reckless brother of DevOps both bring a consolidated set of tools to develop, test and deploy software, but MLOps introduces another variable to the equation "Data" which was not considered in DevOps but is a first citizen in MLOps.
Deploying an ML model in Production is way more complicated than playing with a model on a laptop compare. The model itself is just a small fraction of the overall code needed to guarantee a robust, scalable and reliable deployment. Below image has been taken from a paper published by Google research Hidden Technical Debt in Machine Learning Systems (D. Sculley et. al. NIPS 2015)
![]() |
| [D. Sculley et. al. NIPS 2015: Hidden Technical Debt in Machine Learning Systems] |
ML Project Lifecycle
Machine Learning project life cycle is composed by a set of step a summary of it is presented in the schema below
![]() |
| https://www.coursera.org/learn/introduction-to-machine-learning-in-production |
Scoping
Scoping is the first phase of the project, during this phase use cases and performance metrics are defined often business and data science team opinion diverges on which performance metrics to consider, for instance assume a start-up is developing a model to recommend products in a e-commerce site, business and technical teams are discussing on which performance metric to adopt, technical team may look at the click rate while business to the revenues generated. Another important aspect that is defined during the initial stage of ML lifecycle is the feasibility to defined it we can check academic literature on the topic, similar attempts done by competitors, set a baseline and implement a quick POC. Another important aspect to consider during the scoping phase and the business case selection are the ethical considerations: Is the project adding value for the company and for the community or is a threat for people privacy or freedom.
Baseline Definition
Define a baseline for the model to understand what is the level of performance that can be achieve setting the Bayes error or irreducible error in order set up the boundaries and avoid to commit on an unrealistic set of goals. Use cases that require unstructured data like computer vision, natural language processing etc. the Human Level Performance (HLP) as benchmark to define the expected model performance for instance if the HLP is 90% we can decide that our model will be good enough if it reaches 80% accuracy. For what it concern the lower bound and to set reasonable expectations we can use as baseline the performance of a naïve model.
After we understand which problem we want to tackle with machine learning we need to find the data.
Data
Data Gathering
Data can be sources in several ways: by the business application within the enterprise (Sales, Click Streams), retrieved online (search engine images, large corpus of text) or can be generated (product line camera, sensors etc.).
Dataset collected can come in different sizes and forms, below table summarize the main typologies of dataset we can encounter in our ML projects divided by size and type
Structured | Unstructured | |
Small | Housing Price Prediction | X-Ray Classification |
Big | Online e-commerce click prediction / recommendation | Speech recognition, Twits Sentiment Analysis, NLP task trained on large corpus of text |
Most of the ML model created nowadays are supervised learning models, it means that the model expects to have a label associated to each example in the training set. Obtaining unlabeled data it is relatively easy for example you can just download thousands of images from internet or place a camera on our product line or download a large corpus of text from Wikipedia, while create a labeled dataset is complex and expensive to generate and maintain, How are we going to label the data?
In some cases labels are simply generated as past events (e.g. time series), sometimes data is generated by the final users / client of a process e.g. product click, sale related to a recommendation, ads click. For Process generated label the business application is responsible to collect the labels online as part of the transaction or is extracted offline through a backend process from logs.
In other cases typically with unstructured (image segmentation, classification etc.) the labelling process can be performed:
Manually
- Crowdsourcing leverage online labelers covering general use cases like identifying object in an image, label images etc. Is a relative cheap method and easily scalable. (e.g AWS Mechanical Turk)
- SME (Subject Matter Experts) in some cases the labelling process needs to be done by highly skilled expert, in this case the labelling process is costly and hard to scale. For example
- Process Input the data is labeled as part of the business application process, for instance a model that suggest an online advertised can have an immediate feedback if the customer clicked on the banner.
Automatically or semi-automatically
- Semi-supervised uses set of representative labelled example and propagate it to other examples by similarities of close to the reference example in the feature space.
- Active learning iterative technique that intelligently selects which example to label and propagate the label to other examples based on their position compared to the decision boundaries.
- Weak supervision define a set of heuristics to label automatically the training dataset, afterwards it uses a GAN model to de-noise the input.
Data augmentation is a technique used to increase the number of labelled example, the technique is effective with unstructured dataset, it uses transformations like mirroring, flipping, cropping on images or adds background sounds in case of audio. It can increase substantially the size of the training set and decrease model sensitivity.
Data Security and Fairness
It is important to remember that privacy individuals should be protected while collecting data for our ML projects we do not want any personal information to leak, being shared or compromised. There are several types of attacks that can threat the security of data we are handling. One example of data security threat is the re-identification attack. As you may not know even if data is anonymized it still keeps a digital finger prints, researches has shown that 87% of the Americans can be identified by three pieces of information gender, birth day and zip code. An interesting and disturbing example of re-identification was linking the New Your Cab dataset which includes pick up and drop off locations and timestamps matched with paparazzi photos to identify VIPs home locations
![]() | |
| https://azure.microsoft.com/mediahandler/files/resourcefiles/microsoft-smartnoisedifferential-privacy-machine-learning-case-studies/SmartNoise%20Whitepaper%20Final%203.8.21.pdf |
Even with aggregated data some specific aggregation bucket can have only one record underlying which is subject to re-identification. A secure open data sharing approach is check for k-anonymity, to have a secure privacy protection requires 5-anonymity meaning that the dataset as at least 5 records aggregated on each combination of gender, zip code and birth date.
Another technique worth mentioning in case we need to use cloud computation service but we have data residency constraints is homomorphic encryption, it allows to train ML models on encrypted data typically on the cloud without sharing unencrypted data or encryption keys with cloud provider / or third parties.
Data Quality, Label Quality
Do we need Big Data to succeed in our ML projects, actually is not necessary to reach good results and sometimes we don’t have a lot of data to work with. The fundamental thing specially with small dataset (e.g. x-ray labelled by experts) is the data quality. In particular labelling process should be consistent it can otherwise degrade the performance of the model. Need to give precise guidelines to the labelling people to ensure a uniform practice.
ML Modeling
This is the phase when we are going train the model, let's see the key aspects to keep in mind
Collect Metadata
Metadata collection is a fundamental step throughout all ML lifecycle, we must be able to extensively track all the artifact generated during ML model experimentation, training, deployment and monitoring, the metadata collected include data, data distribution, dataset schema, parameters and code.
Dataset schemas and distribution will be used once the model is deployed in production to identify data drifts and training-inference skews.
Code (model and data pipelines) and data used during the model experiment and training need to be tracked to guarantee Model reproducibility. Versioning training datasets cannot be done with a simple code repository due to the large amount of space required dedicated technology have been developed for this purpose e.g. pachyderm, git LFS, DVC. Reproducibility is the ability to replicate previous results and to compare it with newer version of the model to benchmark improvements.
Data provenance is tracked to interpret the results and to help understanding how the model evolved over time.
Feature Engineering
Once we have collected our training set the data science team start experimenting and manipulating the dataset in a phase of the ML lifecycle called feature engineering which aims to convert raw data into feature vector to be input for the model training phase. There are different transformations that can be applied at this stage normalization (features between [0,1]), standardization (mean centered to 0), feature crosses which combine multiple features together to create new features (sum, subtractions, power etc.), one hot encoding, embeddings etc. The same set of transformations should be applied during training and inference phases in order to avoid training-inference skew issues. If the data input is transformed in a different way during the inference phase the model will not work as expected.
Feature Selection (Dimensionality Reduction)
A feature space with an high number of features will lead to what is called curse of dimensionality increasing the model variance or overfitting. More features means more storage and computation resources during training and inference phase. Select the most relevant features will improve the model in terms of overall accuracy, cost and performance.
Feature selection goal is to remove feature that are redundant or that are not bringing any predictive signal. There are several ways to perform feature selection:
- Correlation (Pearson, Kendall Tau Rank, Spearman Rank etc.) to spot highly correlated / redundant features to filter it out keeping only highly correlated feature in respect to the label.
- Iteratively execute a baseline model including/removing the features one by one and studying their impact on the model results keeping the top N features as result, or leveraging feature importance generated by certain models (e.g random forests).
- On the unsupervised front we can use dimensionality reduction techniques e.g PCA Principal Component Analysis (also SVD, ICA, LDA) the algorithm mathematically removes less relevant features. A cons of this technique is that it reduces the explainability of the final model.
The output of this stage is stored in repository that is gaining momentum as standard component of the MLOps ecosystem called Feature Store.
Model Selection and Data Centric Approach
During the last years where there was an explosion of the AI and ML research the main focus was on develop better and more complex model using data as a fix variable usually on open source dataset (e.g. ImageNet or typical Kaggle challenge). Has been demonstrated that improving the quality of a dataset can improve the performance of the ML model in some cases simpler models end up performing better than complex models. There is a wide movement within the AI and ML community to shift from a strong model centric approach to a more data centric approach (Model Centric to Data Centric). It is particularly important to improve the quality of the data when we need to deal with a small dataset as a single mislabeled instance cannot be easily average out as it would happened in a large dataset.
One of the most important aspect we need to define upfront, actually during the scoping phase how are we going to measure the performance of the model and what level of performance we want to achieve.
Error Analysis
During the model selection and training is important to perform an accurate error analysis breaking down the error by different categories and compart and compare it with a base line and a bayes error (both established during the scoping phase) will help the data science team to prioritize the their work considering slice of data that are underperforming and have a bigger rate of improvements compared to the irreducible error. Using confusion matrix, precision, recall and F1 Score will help to have a better view of the model performance.
Model biases can be caused by skewed datasets with rare cases (e.g. xrays of a particular pathology) a training set can have 99% of negative cases healthy patients (labeled 0) and just 1% of patients with a pathology (labeled 1) in this case a naïve model that predict always 0 (patient that not present any pathology) will have 99% accuracy. There are Possible ways to mitigate bias of skewed dataset:
- oversampling the under-represented slice (e.g. SMOTE)
- data augmentation
- stratified sampling
Skewed datasets and biased model are not just limiting the performance of our ML system, a more disturbing problem unfair model predictions.
Model Fairness Example
For example imagine a classification model used by a bank for load approvals, the model has a recall score of 0.70 meaning that it identify 70% of the cases where the client is going to repay the loan. We analyze the recall on a sensitive group like age and we find out that for people younger of 25 year the recall is 0.5 and 0.83 form clients older than 25 there is a disparity of 33% among the two age groups so we can confidently state that our model is biased.
![]() |
| from: building AI solutions with Azure ML services |
Possible causes of the unfair model behavior might be data Imbalance, overrepresented groups, indirect correlations which may induce the algorithms to assign incorrect weights to a feature which may cause an unfair predictions.
As mentioned in the previous section perform error analysis across the relevant slices of the training dataset to ensure model fairness. In general is always preferable to trade off the overall model accuracy to increase model fairness.
Deployment
Once we have developed our model and it satisfies our expectations in terms of performance, fairness and security our journey to production is just started, deploying a model in production present several challenges and engineering complexities.
During the experimentation, features engineering and model training the work is done by the data science team on a small scale to allow quick prototyping. Once we have a good model and related transformation pipeline, the artefacts pass through a process of engineering to train the model on the full training dataset and make the software production ready.
The software is packaged and containerized to be deployed into production. ML model management in production is handled by a component called model server which allow the deployment of models at scale, performance and model lifecycle management. Below an high level diagram that represent the main blocks of a model server
A model can be deployed in different ways, below a list of the most common approaches:
- Blue/Green deployment: a new version (green) of the model is deployed, all the traffic is redirected to the new version while the old version (blue) stays online as backup. If the new model does not behave as expected the traffic is rolled back to the blue version
- Shadowing: a new model is deployed in production the traffic is sent to both the old and new model, predictions of the old model are sent to the downstream applications while the ones of the new model are used for evaluations and compared with the old one. Sometimes there is no existing model deployed to compare with but the model is used to shadow a human operator.
- Canary Deployment: once the new model is deployed in production a small percentage of the traffic is routed from the old to the new model to minimize disruption on the downstream applications in case the model does not work as expected, gradually the traffic is redirected to the new model.
When a model is deployed is important to maintain exactly the same application environment used during the training (library versions etc.) in order to avoid train-serving skew.
Monitoring
Once in production we need to keep monitoring our model. Consider that a model is designed to provide prediction based on a certain knowledge of the world learned during the training phase from historical data. The world is not immutable is in a constant change and evolution sometimes slowly and sometimes quickly as it happened in 2020 with the Covid19 pandemic. Our model get stale with time and need maintenance sometime it needs to be retrained or sometimes changed entirely. There are several challenges threateing the quality of the model predictions:
- Data drift: happened when the distribution of the inputs in production diverge from the distribution we have used during the model training. For example imagine a model with recommend products on an online e-commerce which historically had a client base of people over 45, but now the website is gaining a young audience the model is not trained on this kind of customers so its predictions might be less accurate.
- Concept drift: denotes a change in the patterns learned by the model, in other works the function that maps inputs and outputs has changed. Concept drift can be a slow over time, a sudden and unexpected or seasonal. Inputs distribution can be the same compared to the training set but its relationship with the predicted outputs has changed. A disturbing example happened to the real estate website Zillow. The company used a set of predictive models to buy and re-sell properties, in 2020 Covid-19 pandemic dramatically changed the world and US real estate market, due to the concept drift became less accurate. At the end of 2021 Zillow registered a total loss of 600 M $ and had to lay off 25% of its workforce.
- Training-Serving skew: it is similar to data drift but in this case the model has been trained on a dataset that does not match with the real world so as soon at is deployed in production its performance plunges. For instance a computer vision used to identify product defect on a production line and the images used for the model training have been taken from a different camera compared to the one used in production with a different exposure, illumination or position.
- Data Quality: inputs received from the source applications are corrupted or missing. Field with Null or N/A values, numeric values out of range (e.g. negative individual age), overflowing strings. In this case counts the well know garbage in garbage out way of saying.
How should we actively monitoring our model to minimize the harm caused to it:
- Input Monitoring: Assess new inputs to verify that the schemas of the new batches is compatible with the one used during training in terms of number of feature, domains and accepted values. We need to verify that the statistical distribution of the inputs dataset is in line with what we have used during the training phase in terms of means, standard deviations etc. Both schemas and input statistics should have been saved in a metadata repository during the training phase to be used once in production.
- Inference Monitoring: monitor the output of the model to compare predictions with human labeler, user behavior or business processes, in general to be able to assess the ground truth and identify concept drifts.
- Infrastructure Monitoring: monitor basic infrastructure metrics like number of requests, CPU and memory consumption which can be indicators that something is changing in the way users interface to the inference API







Comments
Post a Comment