We close the introductory module with the most practical lesson of all: the complete lifecycle of a Machine Learning project. A model doesn't appear by magic; it is the result of a process with well-defined phases, from defining the business problem to monitoring the model in production. This lesson serves a double purpose: it gives you the standard professional process, and it also works as a map of the course, because each phase of the workflow corresponds to one or more modules we will study in detail. To keep it from being abstract, we will walk the workflow from start to finish with a guided example: MercaFresh's customer churn problem, at a high level and without complex code.
Contents
- Overview: the workflow and its iterative nature
- Phase 1: Problem definition
- Phase 2: Data collection
- Phase 3: Data exploration
- Phase 4: Preprocessing
- Phase 5: Model training
- Phase 6: Evaluation
- Phase 7: Deployment and monitoring
- The workflow as a map of the course
- Guided example: MercaFresh churn from start to finish
Overview: the workflow and its iterative nature
The standard workflow has seven phases. The first thing you should know is that it is not a straight line but a cycle with loops back: it is normal to discover during evaluation that data is missing, or during exploration that the problem was poorly defined, and to go back. Real projects go around the loop several times before reaching production.
flowchart TD
A[1. Problem definition] --> B[2. Data collection]
B --> C[3. Data exploration]
C --> D[4. Preprocessing]
D --> E[5. Model training]
E --> F[6. Evaluation]
F -->|Results good enough| G[7. Deployment and monitoring]
F -->|Results insufficient| D
F -.->|Missing data or signal| B
C -.->|The problem was poorly framed| A
G -.->|Performance degrades over time| B
A golden rule that surprises beginners: in a typical project, most of the time (often 60-80%) goes into phases 2-4 (data), not into training models. Training is the most glamorous phase and, almost always, the shortest.
Phase 1: Problem definition
Everything starts with the business, not the data. This phase answers:
- What decision do we want to improve? ("Which customers to target with the retention campaign").
- What type of ML problem is it? Applying the guide from lesson 01-03: regression, classification, clustering...?
- What will the success metric be? Both the technical one (hit rate) and the business one (cut cancellations by 15%). This is the P in Mitchell's definition (lesson 01-01).
- What is the baseline? The current simple solution the model will have to beat (lesson 01-04).
- Is it feasible and worth it? The 6 conditions we studied in the previous lesson.
A well-defined statement has this shape: "Predict [what] for [whom/when] using [what data], measuring success with [metric], to improve [business decision]".
Phase 2: Data collection
Locating, extracting and joining the relevant data:
- Internal sources: the orders database, the customer CRM, the website logs.
- External sources: the holiday calendar, weather data, public demographic data.
- Building the label (in supervised problems): operationally defining what a "positive" is. It sounds trivial and it isn't: what exactly is a customer who "churns" from an online supermarket, when nobody ever "cancels an account"? It will have to be defined (e.g., "90 days without a purchase").
The practicalities of handling this data with pandas will appear throughout the course starting in module 3.
Phase 3: Data exploration
Known as EDA (Exploratory Data Analysis): looking at the data before touching it.
- Descriptive statistics: means, medians, ranges, distributions (all of this is module 2).
- Visualizations: histograms, scatter plots, time series.
- Relationships between variables: correlations (lesson 02-03).
- Surprises: impossible values (200-year-old ages), duplicates, gaps, imbalances (only 4% of customers churn?).
Exploration frequently rewrites the project: this is where you discover that the key variable hasn't been recorded since 2024, or that 30% of customers have no postal code on file.
Phase 4: Preprocessing
Raw data is almost never usable as is. You have to:
- Clean: fix errors, remove duplicates (03-01).
- Handle missing values: drop or impute (03-02).
- Transform and encode: convert categories like "city" into numbers the algorithm can understand (03-03, 03-04).
- Scale: normalize or standardize magnitudes (03-05).
- Create new features using business knowledge (feature engineering, 03-06): for instance, "days since last purchase" doesn't exist in the database, it is computed — and it tends to be the most predictive churn variable.
We dedicate all of module 3 to this work, because it is where the quality of the model is won or lost.
Phase 5: Model training
At last, the "star" phase (and the shortest one):
- Choose one or several candidate algorithms suited to the problem type (those of module 4 if supervised, those of module 5 if unsupervised).
- Train them on the prepared data (the
fit()you already know from lesson 01-01). - Tune their configuration (the hyperparameters, which we will optimize in module 7).
In professional practice, several algorithms are tried and compared; it is rarely known in advance which one will work best on your data.
Phase 6: Evaluation
Is the model genuinely good? Answering that rigorously is the whole of module 6:
- Split the data into training and test sets, so you measure on examples the model never saw (06-01): the ability to generalize we mentioned in lesson 01-01.
- Compute metrics appropriate to the problem (06-02, 06-04): with only 4% of customers churning, a useless model that always says "stays" is right 96% of the time; that is why choosing the metric well is critical.
- Detect overfitting/underfitting (06-05): memorizing the past is not learning.
- Compare against the baseline and against the business metric defined in phase 1. If it doesn't beat them, you go back to phase 4 (or phase 2): the cycle in the diagram.
Phase 7: Deployment and monitoring
A model that lives on the analyst's laptop generates no value. You have to:
- Deploy it: integrate it into the real systems (an API the CRM queries, a nightly job that scores all customers) — module 8 (08-01, 08-02).
- Monitor it: the world changes (new habits, new products, a pandemic...) and model performance degrades over time (a phenomenon known as drift). You must watch the metrics and retrain periodically (08-03).
- Govern it: ethics, privacy and regulatory compliance (08-04).
That is why the last arrow of the diagram loops back to the beginning: an ML project doesn't "finish"; it is maintained.
The workflow as a map of the course
This table is your navigation map for the whole course: each phase of the workflow points to where it is studied in depth.
| Workflow phase | What is done | Where it is studied in this course |
|---|---|---|
| 1. Problem definition | Objective, problem type, metric, baseline, feasibility | Module 1 (lessons 01-03 and 01-04) |
| 2. Data collection | Sources, extraction, label construction | Cross-cutting (modules 3 and 9) |
| 3. Exploration (EDA) | Statistics, distributions, correlations | Module 2 |
| 4. Preprocessing | Cleaning, missing values, encoding, scaling, features | Module 3 |
| 5. Training | Supervised / unsupervised algorithms | Modules 4 and 5 |
| 6. Evaluation | Data splitting, metrics, validation, over/underfitting | Module 6 |
| (Iterative improvement) | Regularization, ensembles, hyperparameters | Module 7 |
| 7. Deployment and monitoring | Production, maintenance, ethics | Module 8 |
| The whole cycle, integrated | Complete projects from start to finish | Module 9 |
Guided example: MercaFresh churn from start to finish
Let's now walk the full cycle with the problem that will accompany us through several modules. All at a high level: the technical details will arrive in their modules.
Phase 1 — Definition. Management notes that acquiring a new customer costs about 5 times more than retaining an existing one. Project statement: "Predict which active customers will stop buying within the next 90 days, using their order and browsing history, measuring success by the proportion of churns correctly anticipated, in order to target them with a coupon-based retention campaign". It is a supervised, binary classification problem (lesson 01-03). Current baseline: the marketing team sends coupons to anyone who hasn't bought in 60 days, with no further criteria.
Phase 2 — Collection. 24 months of history are pulled from the order system, and each customer's data from the CRM. A key decision: "churn" is defined as 90 consecutive days without a single order. With that definition the label is built: for each customer, looking back from a past cutoff date, we know whether they churned in the following 90 days (1) or not (0).
Phase 3 — Exploration. First findings: only 7% of customers churn per quarter (heavily imbalanced classes, which will shape the metric in phase 6); some customers are duplicated because they registered with two email addresses; and purchase frequency visibly drops in the weeks before churn — good news: there is signal to learn.
Phase 4 — Preprocessing. Duplicates are removed, missing postal codes are imputed, the city is encoded as a numeric variable, and features are created with business knowledge: days_since_last_purchase, orders_last_quarter, avg_basket_change, recent_delivery_incidents.
Phase 5 — Training. Two or three candidate classifiers from module 4 (for example, logistic regression and decision trees) are trained on the prepared data. Conceptually, the scene is one you already know:
# The heart of the project, conceptually (the details come in modules 3-6)
model.fit(X_train, y_train) # learns from past customers
probabilities = model.predict(X_customers_today) # scores the current customersTwo lines that condense weeks of work: X_train is the outcome of phases 2-4 (historical customers described by their features), y_train is the label built in phase 2, and the prediction assigns each current customer their churn risk.
Phase 6 — Evaluation. The model is measured on customers it never saw during training. Given the imbalance (7%), the raw hit rate is misleading, so metrics appropriate to the problem are used (those of 06-02 and 06-04). The model catches 71% of future churns versus the ~35% captured by the 60-day rule: it clearly beats the baseline.
Phase 7 — Deployment and monitoring. Every Monday, an automated job scores all active customers and sends the high-risk list to the CRM; marketing targets them with the retention campaign. Two things are monitored: the quality of the predictions (is it still accurate?) and the business outcome (are cancellations going down?). Six months later, a change in the mobile app alters browsing patterns and performance drops: the model is retrained on recent data. The cycle continues.
Common Mistakes and Tips
- Starting with the model instead of the problem. Training without a defined success metric and baseline is walking without a compass; phases 1-3 are not bureaucracy, they are the project.
- Underestimating the data work. Reserve, in your (mental and real) planning, most of the effort for phases 2-4; that is what you will find in any professional team.
- Treating the workflow as a rigid waterfall. Going back is not failing: it is the normal operation of the cycle. Budget for iterations.
- Evaluating on the same data you trained on. This is the number one technical mistake of beginners: it produces spectacular, useless results. Module 6 will teach you to avoid it systematically.
- Forgetting the monitoring. A model deployed and forgotten degrades in silence. If nobody watches it, nobody will know when it stopped working.
- Tip: keep this lesson's "workflow → modules" table and come back to it at the start of each module of the course: you will always know which project phase you are working in and why it matters.
Exercises
Exercise 1
Sort these activities of the churn project by the workflow phase they belong to (1-7): (a) discovering that 7% of customers churn per quarter; (b) creating the days_since_last_purchase variable; (c) agreeing with marketing that success will be measured by the proportion of anticipated churns; (d) retraining the model because its performance fell after the app change; (e) defining "churn" as 90 days without buying and building the label; (f) comparing the model against the 60-day rule.
Exercise 2
Write the full project statement (using the template "Predict [what] for [whom/when] using [what data], measuring with [metric], to improve [decision]") for MercaFresh's fresh produce demand forecasting problem introduced in lesson 01-04. Also state what type of problem it is and propose a reasonable baseline.
Exercise 3
In the guided example, exploration revealed that only 7% of customers churn. Explain in 3-4 lines why a model that always predicts "stays" would be right 93% of the time and yet would be completely useless to MercaFresh. Which workflow phase is responsible for avoiding this mirage, and in which module is it studied?
Solutions
Solution 1
- (c) → Phase 1 (problem definition: success metric).
- (e) → Phase 2 (data collection: label construction).
- (a) → Phase 3 (exploration: discovering the class imbalance).
- (b) → Phase 4 (preprocessing: feature engineering).
- (f) → Phase 6 (evaluation: comparison against the baseline).
- (d) → Phase 7 (monitoring and maintenance: retraining upon degradation).
Solution 2
A possible statement: "Predict the units that will sell of each fresh product, for each day of the coming week, using the sales history, the holiday calendar, active promotions and the weather forecast, measuring success by the average error between forecast and actual units sold, in order to improve purchase orders to suppliers and reduce shrinkage and stockouts". It is a supervised regression problem (the label is a number: units sold). A reasonable baseline: the purchasing manager's current rule — the average of the last 4 weeks' sales plus a 10% buffer.
Solution 3
Since 93% of customers don't churn, a model that always answers "stays" matches reality 93% of the time without having learned anything: it identifies none of the at-risk customers, who are precisely the ones the retention campaign cares about. Raw accuracy is a mirage with imbalanced classes. It is avoided by phase 6 (evaluation), by choosing metrics appropriate to the problem, and it is studied in module 6 (especially lessons 06-02 and 06-04).
Conclusion
With this lesson the introductory module closes and the complete process stands mapped out: define the problem with a metric and a baseline, collect and explore the data, preprocess it (where most of the effort lives), train, evaluate rigorously on unseen data, and deploy with continuous monitoring, iterating as many times as needed. You have seen the whole cycle applied to MercaFresh's churn and you have the table connecting each phase to its module: that is your map for the rest of the course. The journey begins with the foundations of the exploration phase: in module 2 we will study the fundamentals of statistics and probability that let you understand your data before modeling it.
Machine Learning Course
Module 1: Introduction to Machine Learning
- What is Machine Learning?
- History and evolution of Machine Learning
- Types of Machine Learning
- Applications of Machine Learning
- The Machine Learning project workflow
Module 2: Foundations of Statistics and Probability
- Basic statistics concepts
- Probability distributions
- Correlation and covariance
- Statistical inference
- Bayes' theorem
Module 3: Data Preprocessing
- Data cleaning
- Handling missing data
- Data transformation
- Encoding categorical variables
- Normalization and standardization
- Feature engineering
Module 4: Supervised Machine Learning Algorithms
- Linear regression
- Logistic regression
- Decision trees
- Support Vector Machines (SVM)
- K-Nearest Neighbors (K-NN)
- Naive Bayes
- Neural networks
Module 5: Unsupervised Machine Learning Algorithms
- Clustering: K-means
- Hierarchical clustering
- Principal Component Analysis (PCA)
- DBSCAN clustering
- Data visualization with t-SNE and UMAP
Module 6: Model Evaluation and Validation
- Data splitting: training, validation and test
- Evaluation metrics
- Cross-validation
- ROC curve and AUC
- Overfitting and underfitting
Module 7: Advanced Techniques and Optimization
- Regularization: Ridge, Lasso and Elastic Net
- Ensemble Learning
- Gradient Boosting
- Deep neural networks (Deep Learning)
- Hyperparameter optimization
Module 8: Model Implementation and Deployment
- Popular frameworks and libraries
- Deploying models to production
- Model maintenance and monitoring
- Ethical and privacy considerations
Module 9: Hands-On Projects
- Project 1: Housing price prediction
- Project 2: Image classification
- Project 3: Sentiment analysis on social media
- Project 4: Fraud detection
- Project 5: Customer segmentation
