Ch.8: Machine Learning Development Life Cycle (MLDLC)
Inspired by: YouTube
In our previous posts, we spent a lot of time focusing on the what and the why of Machine Learning. We discussed what algorithms are, why we use them, the differences between AI and Deep Learning, and the various ways models learn from data.
Today, we are finally shifting our focus to the how. This is the first post where we get highly practical about how Machine Learning products are actually built in the industry.
If you study Computer Science, you will inevitably encounter a topic called Software Engineering, and within it, the SDLC (Software Development Life Cycle). SDLC is a standardized set of guidelines that dictates exactly how to build a software product from start to finish.
As Machine Learning matured in the industry, researchers and engineers realized they needed a similar standardized process specifically tailored for ML-based software. This led to the creation of the MLDLC (Machine Learning Development Life Cycle).
A common mistake students and beginners make is assuming that training a model and getting a good accuracy score is the entire job. In reality, the industry demands engineers who can build end-to-end products. The MLDLC is your roadmap to doing exactly that.
Here is a highly detailed breakdown of the 9 essential steps in the Machine Learning Development Life Cycle.
Step 1: Framing the Problem
You never start a project by blindly writing code. Because you are building a product for a company or client, you must first define exactly what you are trying to solve. You cannot just guess at features midway through development; that wastes time and money.
During this stage, you sit down and answer critical architectural questions:
- What is the exact problem we are trying to solve?
- Who are the end customers?
- What is the budget, and how many people do we need on the team?
- What kind of data will we need, and where will it come from?
- Will this use Supervised, Unsupervised, or Reinforcement learning?
- Will the model run in a Batch (Offline) or Online environment?
Answering these questions gives you a concrete mental model of what the final product will look like before you spend a single dollar on development.
Step 2: Data Gathering
Without data, Machine Learning is impossible. In a college project, you might simply download a clean, ready-to-use CSV file from the internet. In a corporate environment, data gathering is highly complex and messy.
You rarely get handed a perfect CSV. Instead, you might have to:
- Hit External APIs: Write Python scripts to fetch JSON data from external web services.
- Web Scraping: Write scrapers to pull data directly from websites. For example, travel aggregator sites scrape hotel prices from dozens of individual hotel websites constantly.
- Data Warehouses: In large corporations, data is stored in massive, complex databases. You will use ETL (Extract, Transform, Load) pipelines to pull data out of these databases into a Data Warehouse where you can safely interact with it without crashing the live production database.
- Big Data Clusters: If the dataset is massive, you might need to pull it from distributed clusters using tools like Hadoop or Spark.
The goal of this step is to acquire the raw data and store it securely so you can begin working with it.
Step 3: Data Preprocessing
The raw data you just gathered is almost certainly "dirty." If you feed dirty data into a model, you will get terrible predictions. Data Preprocessing involves cleaning the data so your algorithms can safely consume it.
Common preprocessing tasks include:
- Removing Duplicates: Ensuring no redundant data skews the model's understanding.
- Handling Missing Values: Figuring out what to do when a row is missing data (do you delete the row, or try to fill in the blank?).
- Removing Outliers: Stripping away extreme anomalies that would throw off the algorithm.
- Feature Scaling (Standardization): Imagine one column has numbers in the millions (like house prices) and another has decimals (like crime rates). When the algorithm calculates the "distance" between these points, the massive numbers will completely overpower the decimals. You must scale all numbers down to a standardized range so the algorithm treats them fairly.
Step 4: Exploratory Data Analysis (EDA)
Before building a model, you must intimately understand the relationships hidden inside your data. EDA is where you play with the data, visualize it, and find those hidden patterns.
There is a famous quote often attributed to Abraham Lincoln: "If I had six hours to chop down a tree, I'd spend the first four hours sharpening the axe." EDA is sharpening the axe. The more time you spend understanding your data here, the easier model building becomes later.
During EDA, you will perform:
- Univariate Analysis: Analyzing a single column independently (checking its distribution and spread).
- Bivariate Analysis: Analyzing two columns side-by-side to find correlations between them.
- Multivariate Analysis: Analyzing three or more columns together.
- Handling Imbalanced Datasets: If you are building a Cat vs. Dog image classifier, but 90% of your images are cats, your dataset is highly imbalanced. The model will become biased toward cats. You must use specific techniques here to balance the dataset.
Step 5: Feature Engineering and Selection
The input columns in your dataset are called Features.
Feature Engineering is the process of creating intelligent new columns. For example, if you are predicting house prices and have a column for Number of Rooms and another for Number of Bathrooms, you might combine them into a single, more useful column called Total Square Footage. By giving the algorithm a smarter, combined feature, you make its job much easier.
Feature Selection is the process of actively deleting columns. If you have 1,000 features, training your model will take an immense amount of time, and many of those columns likely do not impact the output anyway. You must aggressively select only the vital features that actually contribute to the prediction, dropping the rest to save time and compute power.
Step 6: Model Training, Evaluation, and Selection
Now that your data is perfectly clean and structured, you are ready to train a model. However, you never just train one model.
Because different algorithms excel at different tasks (some are good for text, others for numbers), you bring in algorithms from multiple families (e.g., Naive Bayes, Support Vector Machines, Decision Trees). You train all of them on your data and Evaluate their performance using specific mathematical metrics (such as Classification Accuracy, Regression Error, or Clustering Indices).
Once you select the best performing model, you perform Hyperparameter Tuning. Think of this like adjusting the settings on your TV. When you buy a TV, you tweak the brightness, contrast, and color mode to get the perfect picture. Similarly, you tweak the internal mathematical settings (hyperparameters) of the algorithm to maximize its performance.
Finally, you might use Ensemble Learning (techniques like Bagging, Boosting, or Stacking). This involves taking multiple decent models and combining them together to create a single, incredibly powerful "super model."
Step 7: Deployment
A model sitting on your local laptop does not help any users. You must deploy it into a real software product (a website, a mobile app, etc.).
Typically, you save your trained model into a highly compressed binary file (often using Python tools like pickle). You then wrap that binary file inside an API.
Here is how the architecture looks:
- A user visits your website and fills out a form.
- The website sends that input data to your server (your Python backend).
- The server passes the data to the API.
- The API feeds the data into the binary model, gets the prediction, and sends it back to the user's screen in JSON format.
To make this globally accessible, you deploy this API and your server to cloud platforms like Heroku, AWS (Amazon Web Services), or GCP (Google Cloud Platform).
Step 8: Testing
Once deployed, you do not immediately release it to your entire user base. You perform Beta Testing and A/B Testing. You release the product to a small fraction of your most loyal, trusted users. This allows you to gather feedback, catch real-world bugs, and ensure the model performs exactly as expected in the wild before scaling it up.
Step 9: Optimization (The Cycle Repeats)
The life cycle does not end at deployment. Machine Learning models decay over time as real-world data changes (concept drift). You must constantly monitor the deployed model, gather new user data, and recursively optimize and retrain the system. This ensures your model stays highly accurate indefinitely, looping you right back into the life cycle!
