Machine Learning Engineer
Machine Learning Engineer Roadmap and Interview Guide
This page is a complete roadmap for becoming a machine learning engineer and passing the interviews. It starts from zero with Python and the maths behind models, then moves through data preparation, classical supervised and unsupervised learning, evaluation, deep learning, transformers and finally the production side: serving, pipelines, testing, monitoring and ML system design. Every topic is explained here, so you can learn from this page alone; where a skill has its own detailed roadmap, we summarise it and link to it.
It suits software engineers moving into ML, data scientists who want to ship models rather than notebooks, and graduates in computer science, maths or physics. The second half of the page is an interview guide: the rounds you will face, the levels companies hire at, a 12-week preparation plan, portfolio projects that hiring managers take seriously, and more than twenty questions with the answers a strong candidate gives.
- Level
- Beginner to job-ready
- Time
- 9–15 months from zero at about 12 hours a week; 10–12 weeks of focused interview preparation if you already code and know basic ML
- Scope
- 61 topics in 10 stages
- Before you start
- School-level algebra; the roadmap teaches the linear algebra, calculus and statistics you need; Basic programming in any language, or willingness to start with the Python Roadmap; A laptop that runs Python; free cloud notebooks with a GPU are enough for the deep learning stages
What you will be able to do
- Explain how the main ML algorithms work, including the maths of gradient descent and backpropagation, and choose one for a problem with clear reasons
- Prepare data without leakage: clean it, engineer point-in-time correct features and split it the way the model will be used
- Evaluate models honestly with the right metric, cross-validation, baselines and slice analysis
- Build, train and debug neural networks in PyTorch, including fine-tuning pre-trained CNNs and transformers
- Ship a model as a tested, containerised service and pipeline with experiment tracking and monitoring
- Design an ML system end to end in an interview, from problem framing to online evaluation and retraining
What a Machine Learning Engineer does
A machine learning engineer builds and runs the software that learns from data and makes predictions inside a product. The work covers the whole life of a model: framing a business problem as a prediction task, assembling training data from warehouses and logs, training and evaluating models, and then the part that separates the role from research, putting the model into production where it must be fast, reliable, affordable and monitored. Typical systems include recommendation and ranking, search, fraud and risk scoring, forecasting, computer vision, speech and, increasingly, products built on fine-tuned language models.
ML engineers work with data scientists, data engineers, back-end engineers, product managers and platform or MLOps teams. In smaller companies one ML engineer may do everything from SQL to Kubernetes; in larger ones the role specialises into modelling, ML infrastructure or applied research. What stays constant is the combination: strong software engineering, solid ML judgement and the habit of measuring whether a model actually improves the product.
A typical week
- Write SQL and Python to build training datasets and features from warehouses, event logs and other sources
- Train and compare models, track experiments, and investigate why one model beats another on particular slices
- Turn notebook code into tested pipeline steps and services, and review teammates' pull requests
- Deploy new model versions through shadow, canary or A/B tests and read the results with product and data science colleagues
- Investigate monitoring alerts: a drop in a model metric, feature drift, rising latency or a broken upstream table
- Write design documents for new ML features and discuss trade-offs with product managers and engineers
What is expected at each level
Junior
- Implements well-scoped features, training scripts and evaluation code with guidance, with tests
- Knows classical ML and deep learning fundamentals and uses scikit-learn and PyTorch correctly
- Avoids leakage and evaluation mistakes, and asks for review before claiming a model improvement
- Learns the team's pipelines, deployment process and monitoring dashboards
Mid
- Owns a model or ML feature end to end: data, training, evaluation, deployment, monitoring and retraining
- Chooses methods and metrics independently and runs online experiments with product partners
- Debugs production issues across data, model and service layers
- Writes design documents for single systems and mentors juniors
Senior
- Designs ML systems that span several models and teams, with clear trade-offs on latency, cost and quality
- Sets technical direction for a product area's ML, including what not to build with ML
- Raises standards for evaluation, testing and reproducibility across the team
- Translates business goals into ML roadmaps and explains results to leadership
Staff or Principal
- Shapes the ML platform and modelling strategy across an organisation
- Leads the hardest technical problems, such as new ranking architectures or large-model adoption
- Influences hiring, technical standards and long-term investment decisions
The interview loop
- Recruiter or hiring manager screen30 min
What it tests. Your background, the models you have shipped, whether you lean towards modelling or infrastructure, and level and location fit.
How to prepare. Prepare a two-minute story of one model you built: the problem, the data, the baseline, what you shipped and the measured impact. Know the company's product and guess where it uses ML.
- Coding round45–60 min
What it tests. Data structures and algorithms in Python, at the same bar as software engineers at most companies: arrays, hash maps, heaps, graphs, two pointers and dynamic programming, plus clean code and complexity analysis.
How to prepare. Work through the Data Structures and Algorithms Roadmap and solve problems daily in coding practice. Talk through your approach before coding and test with edge cases.
- ML coding round45–60 min
What it tests. Implementing ML from scratch or with NumPy: k-means, logistic regression with gradient descent, a metric such as AUC, attention, or a data processing task in pandas. Some companies give a take-home instead.
How to prepare. Implement ten core algorithms from scratch in NumPy without notes, and time yourself. Check results against scikit-learn.
- ML fundamentals or breadth round45–60 min
What it tests. Rapid questions on bias and variance, regularisation, metrics, trees and boosting, neural network training, transformers, and how you would debug a model that underperforms.
How to prepare. Practise answering each question in this guide in under two minutes, aloud. Be precise with definitions and give one practical example each time.
- ML system design45–60 min
What it tests. Designing a production ML system end to end: problem framing, labels, features, model, offline and online evaluation, serving architecture, monitoring and iteration. Usually the most important round for mid and senior levels.
How to prepare. Learn the structure in the ML system design topic and practise six classic designs (feed ranking, search, recommendations, fraud, ads click prediction, content moderation) in system design practice.
- Behavioural and project deep dive45 min
What it tests. Ownership, collaboration with data scientists and product, handling failed experiments and incidents, and depth on a past project: why you made each decision and what you would change.
How to prepare. Prepare five stories in situation, task, action, result form, including one failure and one disagreement. Be ready to go three levels deep on your main project.
Skill roadmaps for this role
Each skill below has its own complete roadmap. Learn the core ones first.
- CorePython Roadmap
Python is the language of ML libraries, pipelines and serving code, and of most ML coding rounds.
- CorePython for Data Analysis Roadmap
NumPy, pandas and plotting are how you explore, clean and transform data before any model sees it.
- CoreSQL Roadmap
Training data usually lives in warehouses, and building feature tables needs joins, aggregation and window functions.
- CoreData Structures and Algorithms Roadmap
Most companies run a standard coding round for ML engineers, so data structures and algorithms decide many offers.
- CoreSystem Design Roadmap
ML system design builds on general distributed systems: caches, queues, databases, load balancing and scaling.
- HelpfulDocker Roadmap
Containers make training and serving environments reproducible and are how most models are deployed.
The Machine Learning Engineer roadmap
- Stage 1Foundations: the job and the fieldBeginner · 1 week · 5 topics
- Stage 2Python for machine learningBeginner · 3–5 weeks · 5 topics
- Stage 3Mathematics for machine learningBeginner · 4–6 weeks · 7 topics
- Stage 4Data: sources, formats and preparationIntermediate · 3–4 weeks · 8 topics
- Stage 5Classical supervised learningIntermediate · 4–5 weeks · 7 topics
- Stage 6Unsupervised, semi-supervised and reinforcement learningIntermediate · 2–3 weeks · 4 topics
- Stage 7Model evaluation, validation and the scikit-learn workflowIntermediate · 2–3 weeks · 6 topics
- Stage 8Deep learning fundamentalsIntermediate · 4–6 weeks · 6 topics
- Stage 9Deep learning architectures and applicationsAdvanced · 5–7 weeks · 6 topics
- Stage 10Production ML engineering and system designAdvanced · 4–6 weeks · 7 topics
Stage 1 Foundations: the job and the field
Goal. Explain what machine learning is, what an ML engineer does and how the main kinds of learning differ.
Introduction to Machine Learning Core
Machine learning is a way of building software where the rules are learned from examples instead of written by hand. You give an algorithm data, such as past transactions labelled fraud or not fraud, and it fits a model: a function with parameters tuned so its outputs match the examples. The model is then used on new data it has never seen.
Three ideas carry through this whole roadmap. First, the goal is generalisation, doing well on new data, not memorising the training set. Second, a model is only as good as its data and its evaluation.
Practice. Write one paragraph each for three products you use daily, naming what a model in them predicts, from which inputs, and how success would be measured.
ML Engineer: skills and responsibilities Core
An ML engineer turns models into reliable software. The skills and responsibilities sit on three legs. Software engineering: clean Python, testing, version control, APIs, containers and data structures. Machine learning: choosing, training, evaluating and debugging models, and knowing the maths well enough to reason about failure. Systems: data pipelines, serving models at the required latency and cost, and monitoring them once live.
Compared with a data scientist, an ML engineer usually spends less time on one-off analysis and more on code that runs every day. Compared with a back-end engineer, the extra difficulty is that behaviour depends on data, so a model can fail silently while every health check is green.
Practice. Collect ten ML engineer job posts and tally which skills appear most often; use the tally to rank your own gaps.
ML Engineer vs. AI Engineer Recommended
The comparison ML engineer vs. AI engineer comes up in nearly every career conversation. An ML engineer typically trains models on the company's own data: ranking, fraud scoring, demand forecasting, recommendations, vision models. The work involves feature engineering, training pipelines, evaluation and serving.
An AI engineer usually builds products on top of large pre-trained models accessed by API or hosted in-house: prompt design, retrieval-augmented generation, tool-using agents and evaluation of generated text. The boundary is blurry and moving. If you like maths, data and training loops, lean ML; if you like product building on top of foundation models, look at the AI Engineer page.
Practice. Read three postings for each title and write down five tasks that appear only in one of the two.
Types of Machine Learning Core
The classic types of machine learning are grouped by the kind of feedback the model gets.
- Supervised learning: every example has a label, and the model learns to predict it. Regression predicts numbers; classification predicts categories.
- Unsupervised learning: no labels; the model finds structure such as clusters or a compact representation.
- Semi-supervised learning uses a few labels plus much unlabelled data, for example by pseudo-labelling confident predictions; self-supervised learning creates labels from the data itself, such as predicting a hidden word.
- Reinforcement learning: an agent acts, receives rewards and learns a policy that maximises long-run reward.
Most production ML is supervised. Self-supervised pre-training powers modern language and vision models. Reinforcement learning is used in robotics, games, some recommendation systems and in tuning language models.
Practice. For ten everyday prediction problems, label each as regression, classification, clustering or reinforcement learning, and justify each label in one line.
What is Supervised Learning? Core
What is supervised learning in precise terms? You have pairs of inputs x and targets y, and you want a function f(x) that predicts y on new inputs. You choose a model family (linear, tree ensemble, neural network), a loss function that scores how wrong a prediction is, and an optimiser that adjusts parameters to reduce the average loss on the training data.
The central tension is between underfitting (too simple, high bias, poor even on training data) and overfitting (too flexible, high variance, great on training data and poor on new data). Regularisation, more data, simpler features and proper validation are the tools that manage it.
Practice. Fit polynomials of degree 1, 3 and 15 to 20 noisy points from a sine curve and plot training and test error for each.
Stage 2 Python for machine learning
Goal. Write clean, tested Python and use NumPy, pandas and plotting libraries to load, explore and visualise data.
Basic Syntax in Python Core
Python is the default language of machine learning because the major libraries expose Python interfaces over fast C, C++ and CUDA code. Start with the basic syntax in Python: indentation defines blocks, there are no semicolons or braces, and code reads close to English. Learn variables and data types (int, float, str, bool, None), conditionals with if, elif and else, and Python loops with for over any iterable and while for open-ended repetition.
The Python Roadmap covers the language in depth.
Practice. Write a script that reads a text file, counts word frequencies with a dictionary and prints the top 20, using only the standard library.
Functions and Built-in Functions Core
Functions are how you make ML code reusable and testable. Learn positional and keyword arguments, default values (and why a mutable default such as [] is a bug), *args and **kwargs, return values and type hints. Know the functions and built-in functions you will use constantly: len, range, sorted with a key, min and max, sum, any, all, map, isinstance and open.
Generators with yield let you stream a dataset that does not fit in memory, which is exactly how data loaders work. Handle bad input with exceptions: catch specific types, never use a bare except that hides bugs, and count skipped rows instead of dropping them silently.
Practice. Write a generator that yields fixed-size batches from any iterable, plus three pytest tests for it, including an uneven final batch.
Python Data Structures Core
The four core Python data structures are lists (ordered, mutable), tuples (ordered, immutable, usable as dictionary keys), dictionaries (key to value, average constant-time lookup) and sets (unique items, fast membership tests). The collections module adds Counter, defaultdict and deque, which turn many interview problems into a few lines.
Know the costs: appending to a list is cheap, inserting at the front is linear, and x in list scans everything while x in set does not. Coding rounds for this role use the same data structures and algorithms as general software roles, so pair this topic with the Data Structures and Algorithms Roadmap and regular practice in coding practice. Basic discrete mathematics (counting, sets, graphs and Big-O notation) supports the same rounds; the Computer Science Roadmap covers it.
Practice. Build a vocabulary from a corpus: map each token to an integer id, keep the 5,000 most frequent and map the rest to an unknown token.
Object Oriented Programming Core
Most ML libraries are built around classes. In scikit-learn every model is an object with fit, predict and transform methods; in PyTorch every network is a subclass of nn.Module with a forward method. Understanding object oriented programming lets you read and extend these libraries rather than copy snippets.
Learn classes and instances, __init__, instance and class attributes, inheritance, composition and dunder methods such as __len__ and __getitem__, which make a custom dataset work with a data loader. Prefer composition over deep inheritance trees, and keep state explicit: hidden global state is a common cause of results that cannot be reproduced.
Practice. Write a scikit-learn compatible transformer class with fit and transform that clips numeric columns to percentiles learned during fit.
Essential Python Libraries for Data Analysis Core
The essential Python libraries for data analysis form the base of every ML project. NumPy provides n-dimensional arrays and fast vectorised maths; broadcasting rules let you combine arrays of different shapes without loops. Pandas provides DataFrames for tabular data: reading files, filtering, grouping, joining, reshaping and handling missing values. Learn to think in whole-column operations; a Python loop over a million rows is usually a sign of a missed vectorised method.
Common pitfalls: chained assignment warnings in pandas, silent type coercion when a numeric column contains one stray string, and joins that multiply rows. Check shape and dtypes after each step. Matplotlib and Seaborn draw the diagnostic plots you will need constantly: feature histograms, loss curves, predicted against actual, correlation heatmaps. The Python for Data Analysis Roadmap covers NumPy and pandas thoroughly.
import numpy as np
X = np.random.randn(1000, 3)
X_std = (X - X.mean(axis=0)) / X.std(axis=0) # broadcasting
Practice. Load a public tabular dataset into pandas, report missing values per column, and compute three grouped summaries without any explicit loop.
Stage 3 Mathematics for machine learning
Goal. Use linear algebra, calculus, probability and statistics to explain how models are trained and evaluated.
Linear Algebra Core
Linear algebra is the language of data. A single number is a scalar; a list of features is a vector; a dataset is a matrix with one row per example; a batch of images is a higher-order array. Learning scalars, vectors, and tensors and how their shapes combine is the first step. Most bugs in deep learning code are shape bugs.
Core operations: the dot product (a similarity score and the heart of every linear model), matrix multiplication (a layer of a neural network is XW + b), transpose, identity and norms (L1 and L2, used in regularisation). Know what the determinants and inverse of a matrix tell you: a zero determinant means the matrix squashes space and cannot be inverted, which is why perfectly correlated features break the closed-form solution of linear regression.
Practice. Implement matrix multiplication with plain loops, compare it with NumPy on 200 by 200 matrices, and check both give the same result.
Eigenvalues, eigenvectors and SVD Recommended
An eigenvector of a square matrix is a direction the matrix only stretches; the eigenvalue is the stretch factor. For a covariance matrix, eigenvectors point along directions of greatest variance in the data and eigenvalues measure how much variance each direction holds. That is exactly what principal component analysis computes. Expressing a symmetric matrix as eigenvectors and eigenvalues is called diagonalising it.
Singular value decomposition generalises this to any matrix: A = U S V^T. SVD is used in PCA implementations, in low-rank approximations for compression, in classic recommender systems through matrix factorisation, and in latent semantic analysis for text.
Practice. Run SVD on a small image as a matrix, rebuild it with the top 5, 20 and 50 singular values, and plot the results side by side.
Calculus Core
Training a model means minimising a loss, and calculus tells you which way is downhill. Derivatives and partial derivatives measure how a function changes when one input changes. The gradient, Jacobian, and Hessian extend this: the gradient is the vector of partial derivatives of a scalar loss with respect to every parameter; the Jacobian holds the derivatives of a vector-valued function; the Hessian holds second derivatives and describes curvature.
Gradient descent updates parameters by stepping against the gradient: w = w - lr * grad. A learning rate that is too high diverges; too low wastes compute. The Hessian explains why some problems are hard: in narrow valleys plain gradient descent zig-zags, which is one reason optimisers such as momentum and Adam exist.
Practice. Implement gradient descent for linear regression with NumPy, plot the loss per step for three learning rates and explain each curve.
Chain Rule of Derivation Core
The chain rule of derivation (more usually called the chain rule of differentiation) says that the derivative of a composed function is the product of the derivatives of its parts: if y = f(g(x)), then dy/dx = f'(g(x)) * g'(x). A neural network is a long composition of simple functions, so the chain rule is what lets us compute the gradient of the loss with respect to every weight.
Backpropagation is the chain rule applied efficiently: compute the forward pass and store intermediate values, then walk backwards multiplying local derivatives. Automatic differentiation in PyTorch and TensorFlow does this for you by recording operations on a graph. Understanding it explains vanishing gradients: multiplying many derivatives smaller than one makes the product shrink towards zero in early layers.
Practice. Differentiate the logistic loss of a single neuron by hand using the chain rule, then confirm your result numerically with finite differences.
Probability Core
Models make predictions under uncertainty, so probability is everywhere in ML. Start with the basics of probability: sample spaces, events, conditional probability, independence and the rules for combining them. Bayes' theorem, P(A|B) = P(B|A) P(A) / P(B), updates a prior belief with evidence; it underlies naive Bayes classifiers and explains why a 99%-accurate test for a rare disease still gives mostly false alarms.
Then random variables and probability density functions: a random variable maps outcomes to numbers; discrete ones have probability mass functions and continuous ones have densities that integrate to one. Know expectation, variance and covariance. Classification models output probabilities, and loss functions such as cross-entropy come straight from maximum likelihood, so this topic is the foundation for the evaluation work later.
Practice. Simulate the rare-disease test case with a million random patients and check that the simulation matches Bayes' theorem.
Types of Distribution Core
Knowing the common types of distribution lets you choose sensible models, losses and checks. Bernoulli and binomial describe yes or no outcomes and their counts; Poisson describes counts of events in a fixed window, such as requests per second; normal (Gaussian) describes sums of many small effects and appears through the central limit theorem; exponential describes waiting times; uniform is the starting point for random sampling; long-tailed distributions such as log-normal and power laws describe incomes, prices and popularity.
In practice: a target with a long tail often trains better after a log transform; count targets suit Poisson loss; and assuming normality for latency or revenue data usually gives misleading averages.
Practice. Sample from five distributions with NumPy, plot histograms, and for each name one real ML feature or target that behaves like it.
Statistics Core
Statistics gives you the tools to describe data and to decide whether a difference is real. Descriptive statistics summarise: mean, median, mode, variance, standard deviation, percentiles and correlation. Medians and percentiles matter for skewed data such as latency, where the p99 tells you more than the mean. These basic statistical concepts are asked in screening rounds.
Inferential statistics draws conclusions about a population from a sample: sampling distributions, confidence intervals, hypothesis tests, p-values and statistical power. ML engineers use them when comparing two models offline (is a 0.4% gain real or noise across folds?) and when reading an online A/B test of a new model. Know that a p-value is the probability of data at least this extreme if there were no real effect, not the probability that the model is better.
Practice. Bootstrap a 95% confidence interval for the accuracy difference between two classifiers on the same test set.
Stage 4 Data: sources, formats and preparation
Goal. Collect data from real sources, clean it, engineer and select features, and split it without leakage.
Data Sources Core
Real projects start with finding data, and the main data sources each bring their own problems. Databases (SQL, No-SQL) hold most company data: relational databases and warehouses for transactions and events, document and key-value stores for application state. You must write SQL comfortably to pull training data; the SQL Roadmap covers joins, aggregation and window functions.
Internet data sources include public APIs and web pages, which need rate limiting, retries and attention to terms of use. IoT data sources produce high-volume sensor time series with gaps, clock drift and noisy readings. Mobile app data arrives as event logs with duplicates, late arrivals and changing schemas between app versions.
Practice. Write a SQL query that builds a training table with one row per user and features from the 30 days before a fixed cut-off date.
Data Formats Core
Common data formats trade readability for speed and size. CSV is universal and human-readable but has no types, so dates and IDs with leading zeros get mangled. JSON handles nested records and is the default for APIs and logs, but is verbose. Excel files appear whenever business teams supply labels or reference data; read them with pandas, and watch for merged cells and formulas.
Parquet is a columnar, compressed, typed format and the standard for analytics and ML training data: reading three columns of a hundred does not touch the rest. Other data formats you will meet include Avro and Protocol Buffers for streaming, TFRecord and WebDataset shards for large deep learning datasets, and image, audio and video files.
Practice. Save the same one-million-row DataFrame as CSV, JSON and Parquet, and compare file size and read time for two columns.
Data Cleaning Core
Data cleaning often takes more time than modelling and matters more. Check for missing values and decide per column whether to drop, impute or flag them; a missing-value indicator column is often predictive in itself. Find duplicates, impossible values (negative ages, future dates), inconsistent categories ('UK', 'U.K.', 'United Kingdom'), unit mismatches and outliers.
Look at label quality too; noisy labels cap model performance, and a small audit of a few hundred labelled examples is often the best use of an afternoon. Write every cleaning rule as code, not manual edits, so the same rules run at training time and at prediction time.
Practice. Take a messy public dataset, write a cleaning function with at least six documented rules, and log how many rows each rule changes.
Preprocessing Techniques Core
Models need numbers in a sensible form, and a handful of preprocessing techniques cover most cases. Encoding categories: one-hot for low-cardinality columns, target or frequency encoding for high-cardinality ones (with care to avoid leakage), and learned embeddings in neural networks. Imputation: median for skewed numbers, a constant plus an indicator column, or model-based imputation.
Feature scaling: standardisation (subtract the mean, divide by the standard deviation) or min-max normalisation to a fixed range. Distance-based models (k-nearest neighbours, SVMs, k-means) and gradient-trained models such as neural networks and regularised linear models need scaling; tree-based models do not. Always fit the scaler on training data only and reuse the fitted object at prediction time, otherwise test information leaks into training.
Practice. Train a k-nearest neighbours classifier with and without standard scaling on a dataset whose features have very different ranges, and compare accuracy.
Feature Engineering Core
Feature engineering turns raw data into signals a model can use, and on tabular problems it often beats switching algorithms. Typical features: aggregates over time windows (purchases in the last 7 and 30 days), ratios (clicks per impression), time since an event, date parts (hour, weekday, holiday flags), text lengths and keyword counts, and interactions between columns.
The rule that matters most is point-in-time correctness: every feature must use only information available at the moment the prediction would have been made. Computing a 30-day average that includes days after the label date is the most common cause of models that look excellent offline and fail in production. In production, feature logic must be identical in training and serving; feature stores exist largely to solve this.
Practice. Add five time-window features to a transactions dataset using only data before each row's timestamp, and measure their effect on validation AUC.
Feature Selection Recommended
Feature selection removes features that add noise, cost or risk. Fewer features mean faster training and serving, fewer upstream dependencies that can break, and models that are easier to explain. Methods fall into three groups: filter methods rank features by a statistic such as correlation or mutual information; wrapper methods such as recursive feature elimination train models on subsets; embedded methods select during training, such as L1 regularisation or tree feature importance.
Be careful: selecting features on the full dataset before cross-validation leaks information and inflates scores, so do selection inside each fold. Permutation importance on a validation set is more trustworthy than built-in tree importance, which favours high-cardinality features.
Practice. Compare built-in random forest importance with permutation importance on a dataset where you add a random ID column, and explain the difference.
Dimensionality Reduction Recommended
Dimensionality reduction compresses many features into fewer while keeping most of the useful information. Principal component analysis finds orthogonal directions of maximum variance (the eigenvectors of the covariance matrix) and projects the data onto the top few. Centre and usually scale the data first, and choose the number of components from the cumulative explained variance.
Uses: speeding up models on very wide data, removing correlated features, denoising and visualisation. Non-linear methods such as t-SNE and UMAP make good two-dimensional plots of embeddings but distort distances, so do not use them as model inputs or read cluster sizes from them. Autoencoders, networks trained to compress and then reconstruct their input, learn non-linear compressions and also flag anomalies through high reconstruction error.
Practice. Apply PCA to a handwritten digits dataset, plot explained variance against components and train a classifier on 10, 30 and all components.
Train-Test Data Core
You cannot judge a model on the data it was trained on. Split your data into training, validation (for choosing models and hyperparameters) and test sets (touched once, at the end). Getting train-test data right is the most important evaluation habit in ML.
How to split depends on how the model will be used. For data with time order, split by time: train on the past, test on the future, or your score will be optimistic. When one user has many rows, split by user (grouped splitting) so the model is not tested on people it has already seen. Stratify by class for imbalanced classification. Leakage, where information from the target or the future slips into features, produces suspiciously high scores; when a result looks too good, suspect leakage first.
Practice. Train the same model with a random split and with a time-based split on a dated dataset, and explain the gap between the two scores.
Stage 5 Classical supervised learning
Goal. Train, tune and explain the main regression and classification algorithms, and know when each fits.
Regression Core
Regression predicts a number: a price, a delivery time, demand next week. Linear regression fits y = w·x + b by minimising mean squared error, either in closed form with the normal equation or by gradient descent. It assumes a linear relationship, independent errors and roughly constant error variance; coefficients are interpretable only when features are not strongly correlated.
Polynomial regression adds powers and interactions of features, so a linear model can fit curves; high degrees overfit quickly. Evaluate with MAE (less sensitive to outliers, in the target's units), RMSE (punishes large errors), and R-squared. Plot residuals against predictions: patterns there reveal a missing feature or a needed transform.
Practice. Implement linear regression with the normal equation and with gradient descent, and confirm both match scikit-learn's coefficients.
Ridge, Lasso and Elastic Net Core
Regularisation adds a penalty on large weights to reduce overfitting. Ridge regression adds the squared L2 norm of the weights; it shrinks all coefficients and handles correlated features well. Lasso regression adds the L1 norm; it pushes some coefficients exactly to zero, so it also selects features. Elastic net mixes both penalties, which is useful when there are groups of correlated features and you still want sparsity.
The strength of the penalty, often called alpha or lambda, is a hyperparameter chosen by cross-validation. Scale features first, since the penalty treats all coefficients equally. Interviewers often ask why L1 gives sparse solutions: the L1 constraint region has corners on the axes, so the optimum often lands where some weights are exactly zero.
Practice. Fit ridge, lasso and elastic net over a range of alphas on a dataset with many features and plot how each coefficient changes.
Classification and Logistic Regression Core
Classification predicts a category: spam or not, which of ten products, which defect type. Logistic regression is the baseline: a linear score passed through the sigmoid function to give a probability between 0 and 1, trained by minimising log loss (binary cross-entropy). For several classes, the softmax function generalises it.
Strengths: fast, well calibrated probabilities, coefficients you can explain as changes in log-odds, and strong performance on sparse high-dimensional data such as text. Weaknesses: it cannot model interactions unless you engineer them. The decision threshold does not have to be 0.5; choose it from the business costs of false positives and false negatives.
Practice. Train logistic regression on an imbalanced dataset, then pick the threshold that maximises expected profit given a cost for each error type.
K-nearest neighbours and naive Bayes Recommended
K-nearest neighbours predicts from the labels of the closest training examples. It has no training step, but prediction is slow on large data without an index, it needs scaled features and it struggles in high dimensions where distances stop being meaningful. Approximate nearest-neighbour search, the same idea at scale, powers embedding-based retrieval and recommendation.
Naive Bayes applies Bayes' theorem with the strong assumption that features are independent given the class. The assumption is almost never true, yet the classifier works well for text such as spam filtering because it is fast, needs little data and ranks classes sensibly even when its probabilities are poorly calibrated.
Practice. Build a spam classifier with naive Bayes on word counts and compare it with logistic regression on the same features.
Support Vector Machines Recommended
Support vector machines find the boundary between classes with the widest margin. Only the training points closest to the boundary, the support vectors, define it. The soft-margin parameter C trades margin width against training errors. The kernel trick lets an SVM learn non-linear boundaries by computing similarities in a higher-dimensional space without building it; the RBF kernel is the common default, with gamma controlling how local each point's influence is.
They still work well on small and medium datasets with clear margins, but training scales poorly beyond a few hundred thousand rows and they do not output calibrated probabilities by default.
Practice. Fit linear and RBF SVMs on a two-dimensional toy dataset and plot the decision boundaries for three values of C and gamma.
Decision Trees and Random Forests Core
A decision tree splits data with a sequence of yes or no questions on features, choosing each split to reduce impurity (Gini or entropy for classification, variance for regression). Trees need no scaling, handle mixed feature types and are easy to explain, but a single deep tree overfits badly.
A random forest trains many trees on bootstrap samples, with a random subset of features considered at each split, and averages their predictions. This bagging reduces variance without much increase in bias. Know the key hyperparameters: number of trees, maximum depth, minimum samples per leaf and features per split. Together, decision trees and random forests are a standard interview topic.
Practice. Train a single tree at depths 2 to 20 and a random forest on the same data, plot validation scores and explain the shapes.
Gradient Boosting Machines Core
Gradient boosting machines build trees one after another, each fitted to the errors (the negative gradient of the loss) of the ensemble so far. Boosting reduces bias, and with a small learning rate and many shallow trees it is the strongest default for tabular data. XGBoost, LightGBM and CatBoost are the common libraries; they add regularisation, fast histogram-based splitting, native handling of missing values and, for CatBoost, careful treatment of categorical features.
Key hyperparameters: learning rate, number of trees (use early stopping on a validation set), tree depth or number of leaves, row and column subsampling, and minimum child weight. Explain bagging versus boosting clearly in interviews: bagging averages independent high-variance models; boosting adds dependent weak models sequentially.
Practice. Tune a LightGBM or XGBoost model with early stopping and compare it with a random forest and logistic regression on the same split.
Stage 6 Unsupervised, semi-supervised and reinforcement learning
Goal. Group unlabelled data, use partial labels, and explain how reinforcement learning agents learn from reward.
What is Unsupervised Learning? Core
What is unsupervised learning? It is learning structure from data without labels. Main tasks: clustering (grouping similar items), dimensionality reduction (compact representations), density estimation and anomaly detection (finding rare, unusual points such as fraud or failing machines).
The hard part is evaluation. With no ground truth, you judge results by internal measures such as the silhouette score, by stability across runs, and above all by whether they are useful for the task: do customer segments behave differently, do flagged anomalies turn out to be real when someone checks them?
Practice. Run an isolation forest on a transactions dataset, inspect the 20 most anomalous rows and write down which look like real problems.
Clustering Core
Clustering algorithms differ in how they assign points. Exclusive clustering puts each point in exactly one group; k-means is the standard example, alternating between assigning points to the nearest centroid and moving centroids to the mean. It needs k in advance, assumes roughly round clusters of similar size and is sensitive to scaling and initialisation (k-means++ helps).
Overlapping clustering lets a point belong to several groups, as in fuzzy c-means. Hierarchical clustering builds a tree of merges (agglomerative) and lets you cut it at any level; it suits small datasets and gives a dendrogram. Probabilistic clustering, such as Gaussian mixture models, gives each point a probability of belonging to each cluster and handles elliptical shapes. DBSCAN finds dense regions of any shape and labels sparse points as noise.
Practice. Cluster the same customer dataset with k-means, a Gaussian mixture and DBSCAN, and compare the groups with silhouette scores and a two-dimensional plot.
Self-Supervised Learning Recommended
Self-supervised learning creates labels from the data itself, so it can learn from huge unlabelled collections. Language models predict the next or a masked word; vision models learn by matching two augmented views of the same image (contrastive learning) or reconstructing hidden patches. The result is a general representation, or embedding, that transfers to many tasks.
This is why modern ML engineering often starts from a pre-trained model instead of training from scratch: you fine-tune a model that has already learned from billions of examples on a few thousand of your own.
Practice. Extract embeddings from a pre-trained image model for a small labelled dataset and train logistic regression on them; compare with training a small CNN from scratch.
What is Reinforcement Learning? Optional
What is reinforcement learning? An agent observes a state, takes an action, receives a reward and learns a policy that maximises total discounted reward, balancing exploration of new actions against exploitation of known good ones. Feedback is delayed and depends on the agent's own choices, which makes it harder than supervised learning.
Q-learning learns the value of each action in each state; Deep Q-Networks (DQN) replace the table with a neural network plus experience replay and a target network. Policy gradient methods adjust the policy directly towards actions that earned high reward. Actor-critic methods combine both, with a critic estimating values to steady the actor's updates; PPO is the widely used example, including in tuning language models from human feedback. Contextual bandits, a one-step version, are common in recommendation and pricing.
Practice. Implement an epsilon-greedy multi-armed bandit over five arms with fixed reward probabilities and plot cumulative regret for three epsilon values.
Stage 7 Model evaluation, validation and the scikit-learn workflow
Goal. Choose metrics that match the business goal, validate honestly, tune hyperparameters and explain predictions.
Model Evaluation: Importance and pitfalls Core
Model evaluation importance is easy to state and often ignored: a model you cannot evaluate honestly is a model you cannot ship. Offline evaluation tells you whether a model is likely to help; online evaluation (an A/B test or a shadow deployment) tells you whether it actually does.
Typical pitfalls: leakage, random splits on time-ordered data, a test set reused so often it became a validation set, a metric that does not match the product goal, ignoring slices (the model is good overall but poor for new users or one country), and comparing against no baseline. Always report a simple baseline, such as predicting the mean or the majority class, or the current rule-based system, next to your model.
Practice. Write an evaluation report for one model with a baseline, an overall metric, five slices and a list of known weaknesses.
Model Evaluation Metrics Core
Classification model evaluation metrics start from the confusion matrix: true positives, false positives, true negatives, false negatives. Accuracy is the share correct and is misleading on imbalanced data. Precision is the share of predicted positives that are real; recall is the share of real positives found. The F1-score is their harmonic mean. ROC-AUC measures how well the model ranks positives above negatives across all thresholds; with heavy imbalance, PR-AUC is more informative. Log loss scores the probabilities themselves and punishes confident mistakes harshly.
For regression: MAE, RMSE, MAPE (unstable near zero) and R-squared. For ranking: precision at k, recall at k, NDCG and MAP.
Practice. From a model's predicted probabilities, compute the confusion matrix, precision, recall and F1 by hand for thresholds 0.3, 0.5 and 0.7.
Validation Techniques Core
A single split gives a noisy estimate. K-fold cross validation splits the data into k parts, trains on k minus one and tests on the remaining one, rotating through all k; you report the mean and spread. Five or ten folds are common. Stratified k-fold keeps class proportions in each fold. Leave-one-out cross-validation uses every single example as its own test set; it is nearly unbiased but expensive and high-variance, so it suits only very small datasets.
Other validation techniques: grouped k-fold when rows from one entity must stay together; time-series split with an expanding or sliding window for temporal data; and nested cross-validation when you need an unbiased estimate after tuning. All preprocessing must happen inside each fold, which is what scikit-learn pipelines make easy.
Practice. Compare 5-fold, 10-fold and leave-one-out estimates on a 200-row dataset, and report the mean and standard deviation for each.
Scikit-learn Core
Scikit-learn is the standard library for classical ML, and its consistent interface is worth learning well. Data loading in scikit-learn covers built-in toy datasets and fetchers, though real work loads data with pandas. Data preparation in scikit-learn uses transformers such as StandardScaler, OneHotEncoder and SimpleImputer, combined with ColumnTransformer and Pipeline so the exact same steps run in training and prediction.
Model selection in scikit-learn covers train_test_split, cross-validation helpers and search classes. Model prediction in scikit-learn uses predict and predict_proba on the fitted pipeline, which you can save with joblib. Scikit-learn for neural networks offers MLPClassifier and MLPRegressor, fine for small problems but no replacement for PyTorch.
pipe = Pipeline([
('prep', ColumnTransformer([
('num', StandardScaler(), num_cols),
('cat', OneHotEncoder(handle_unknown='ignore'), cat_cols)])),
('model', LogisticRegression(max_iter=1000))])
scores = cross_val_score(pipe, X, y, cv=5, scoring='roc_auc')
Practice. Build one pipeline with imputation, scaling, encoding and a model, cross-validate it, save it, reload it and predict on new rows.
Hyperparameter tuning Core
Hyperparameters are settings chosen before training, such as tree depth or learning rate. Grid search tries every combination and grows exponentially; random search samples combinations and usually finds good settings faster because only a few hyperparameters really matter. Bayesian optimisation, as in Optuna, models which regions look promising and samples there; early-stopping schedulers such as successive halving and Hyperband drop poor runs early.
In scikit-learn, GridSearchCV, RandomizedSearchCV and HalvingGridSearchCV run the search with cross-validation inside. Good practice: tune on validation data only, use log scales for learning rates and regularisation strengths, fix random seeds, log every run, and stop when gains are smaller than the noise between folds.
Practice. Tune a gradient boosting model with random search and with Optuna at the same budget of 50 trials and compare the best scores.
Explainable AI Recommended
Explainable AI covers methods that show why a model made a prediction. Global methods describe the whole model: permutation importance, partial dependence plots and the coefficients of linear models. Local methods explain one prediction: SHAP assigns each feature a contribution based on Shapley values from game theory, and LIME fits a simple model around one example.
Explanations are used to debug models (a feature that should not matter dominates, which often signals leakage), to satisfy regulation in credit and insurance, to build trust with stakeholders and to give users reasons for decisions. Be honest about limits: explanations describe the model, not causality in the world, and correlated features make attributions unstable.
Practice. Compute SHAP values for a gradient boosting model, plot the summary, and explain three individual predictions in plain language.
Stage 8 Deep learning fundamentals
Goal. Build, train and debug neural networks in PyTorch, and explain backpropagation, losses and optimisers.
Neural Network (NN) Basics Core
Neural network basics start with the neuron: a weighted sum of inputs plus a bias, passed through a non-linear activation. Neurons are arranged in layers; stacking layers lets the network learn increasingly abstract features. Without non-linear activations, any stack of layers collapses into one linear function, which is why activations matter.
The perceptron and multi-layer perceptrons are the historical starting point. A single perceptron draws one straight boundary and cannot learn XOR; a multi-layer perceptron with one hidden layer can approximate any continuous function given enough units, though in practice deeper networks learn more efficiently.
Practice. Build an MLP in NumPy that learns XOR, and show that a single-layer perceptron cannot.
Forward Propagation and Backpropagation Core
Forward propagation computes the output layer by layer: multiply by weights, add biases, apply activations, and finally compute the loss against the target. Backpropagation then applies the chain rule backwards through the same layers to get the gradient of the loss with respect to every weight, reusing intermediate results so the cost is about the same as the forward pass.
An optimiser uses those gradients to update the weights; one forward pass, one backward pass and one update on a mini-batch is a training step. Common problems: vanishing gradients in deep networks with sigmoid activations, exploding gradients in recurrent networks (fixed with gradient clipping) and dead ReLU units.
Practice. Write forward and backward passes for a two-layer network in NumPy and check your gradients against finite differences.
Activation Functions Core
Activation functions add the non-linearity that lets networks learn complex patterns. Sigmoid squashes to 0 to 1 and is used for binary outputs; it saturates and causes vanishing gradients in hidden layers. Tanh is zero-centred but also saturates. ReLU, max(0, x), is cheap and avoids saturation for positive inputs, which made deep networks trainable; its weakness is units that get stuck at zero.
Variants such as Leaky ReLU and GELU fix that; GELU and SiLU are standard in transformers. Softmax turns a vector of scores into probabilities over classes and is used on the output layer for multi-class problems. Choose the output activation to match the task: none for regression, sigmoid for binary or multi-label, softmax for single-label multi-class.
Practice. Plot each activation function and its derivative, and mark the regions where the derivative is near zero.
Loss Functions Core
A loss function turns the gap between predictions and targets into one number to minimise. For regression: mean squared error (sensitive to outliers), mean absolute error and Huber loss, which behaves like MSE for small errors and MAE for large ones. For classification: binary cross-entropy (log loss) and categorical cross-entropy, which come from maximum likelihood. Focal loss down-weights easy examples for heavy class imbalance.
The training loss does not have to be the business metric, but it should be well aligned with it. In PyTorch, pass raw logits to CrossEntropyLoss and BCEWithLogitsLoss; adding your own softmax first is a frequent bug that silently hurts training.
Practice. Train the same regression network with MSE and Huber loss on data containing 5% extreme outliers, and compare test MAE.
Optimisation and regularisation for deep learning Core
Optimisers: stochastic gradient descent with momentum is simple and generalises well; Adam and AdamW adapt the step per parameter and converge faster with less tuning, and AdamW is the default for transformers. Learning-rate schedules matter as much as the optimiser: warm-up, then cosine or step decay. Batch size interacts with learning rate.
Regularisation for networks: weight decay, dropout (randomly zeroing activations during training), batch normalisation or layer normalisation (stabilise and speed training), data augmentation and early stopping on validation loss. A standard debugging step is to overfit a single small batch first: if the network cannot drive training loss near zero on ten examples, there is a bug in the model, data or loss.
Practice. Train a small network with SGD, SGD with momentum and AdamW, each with and without a cosine schedule, and plot all validation curves.
Deep Learning Libraries Core
The main deep learning libraries are PyTorch, TensorFlow and Keras. PyTorch dominates research and is now the most common choice in industry; models are Python classes, execution is eager so you can debug with print statements, and torch.compile adds graph optimisation. TensorFlow has a strong deployment story with TensorFlow Serving and TFLite and remains in many established production systems. Keras is a high-level API for defining and training models quickly; recent versions can run on several back ends.
Learn one deeply; PyTorch is the safest choice. Know tensors and devices, Dataset and DataLoader, nn.Module, autograd, the training loop, mixed precision, saving and loading state dictionaries, and how to export a model for serving with ONNX or TorchScript.
for x, y in loader:
x, y = x.to(device), y.to(device)
opt.zero_grad()
loss = loss_fn(model(x), y)
loss.backward()
opt.step()
Practice. Write a complete PyTorch training script with a custom Dataset, validation each epoch, checkpointing and early stopping.
Stage 9 Deep learning architectures and applications
Goal. Choose and fine-tune CNNs, sequence models and transformers for vision, text and recommendation problems.
Convolutional Neural Networks Core
Convolutional neural networks are built for grid data such as images. A convolution slides a small learned filter over the input and computes a weighted sum at each position, so the same pattern detector is reused everywhere (weight sharing) and the layer respects locality. Early layers detect edges and textures; deeper layers detect parts and objects.
Three settings control the output shape. Padding adds a border, usually zeros, so edges are processed and the size can be kept. Strides set how far the filter moves each step; a stride of 2 halves the resolution. Pooling (max or average) downsamples and adds a little translation invariance. Output size is (n + 2p - k) / s + 1 for input n, padding p, kernel k and stride s; interviewers like asking for it.
Practice. Compute the output shape of each layer of a small CNN by hand, then confirm with a forward pass in PyTorch.
Convolutional Neural Networks (CNNs) Applications Recommended
The main applications of CNNs share a backbone and differ in the head. Image classification with convolutional neural networks assigns one label per image; in practice you fine-tune a pre-trained backbone such as ResNet or EfficientNet. Object detection adds bounding boxes. Image segmentation with convolutional neural networks labels every pixel, using encoder-decoder designs such as U-Net, and is common in medical imaging and autonomous driving.
Image and video recognition with CNNs extends to video with 3D convolutions or frame features plus a temporal model. CNNs for recommendation systems extract visual features from product images, or treat interaction data as a grid, and feed them into the ranking model.
Practice. Fine-tune a pre-trained ResNet on a small image dataset of a few thousand images using augmentation, and report per-class precision and recall.
Recurrent Neural Networks Recommended
Recurrent neural networks process sequences one step at a time, carrying a hidden state that summarises what came before. Plain RNNs struggle with long sequences because gradients vanish or explode over many steps. Long short-term memory networks (LSTMs) add a cell state and gates (input, forget, output) that decide what to keep, which lets them remember over longer spans. The gated recurrent unit (GRU) is a simpler variant with two gates and similar accuracy.
RNNs and their variants still appear in streaming and on-device models, some time-series forecasting, and older production systems.
Practice. Train an LSTM and a GRU to forecast a univariate time series and compare them with a seasonal naive baseline.
Attention Mechanisms and Transformers Core
Attention mechanisms let a model look at all positions of an input and weight them by relevance, instead of squeezing everything into one hidden state. Early attention models added attention on top of RNNs for translation. Self-attention computes, for each token, queries, keys and values; scores are scaled dot products of queries with keys, passed through softmax and used to weight the values. Multi-head attention runs several attention operations in parallel so each head can capture a different relationship.
Transformers stack self-attention and feed-forward layers with residual connections, layer normalisation and positional information. Encoders such as BERT suit classification and embeddings; decoders such as GPT models generate text; encoder-decoders suit translation. Attention cost grows with the square of sequence length, which drives much of the engineering around long context.
scores = Q @ K.transpose(-2, -1) / d_k ** 0.5
weights = scores.softmax(dim=-1)
out = weights @ V
Practice. Implement scaled dot-product and multi-head attention in PyTorch and check output shapes with a batch of random token embeddings.
Natural Language Processing Core
Natural language processing covers models that read or produce text: classification, entity extraction, search, summarisation, translation and question answering. Text must first be split into units. Tokenisation splits text into tokens; modern models use subword tokenisers such as byte-pair encoding or WordPiece, which handle rare words by splitting them into pieces.
Classical pipelines also normalise words. Stemming chops suffixes with rules ('running' to 'run', but also 'university' to 'univers'); lemmatisation maps words to dictionary forms using vocabulary and grammar, which is slower but cleaner. Both help bag-of-words and TF-IDF models and are unnecessary for transformers, which learn from subwords.
Practice. Build a TF-IDF and logistic regression sentiment classifier, then fine-tune a small pre-trained transformer on the same data and compare.
Embeddings Core
Embeddings are dense vectors that represent items such as words, products, users or images so that similar items are close together. Classic word embeddings learned a vector per word from co-occurrence; modern models produce contextual embeddings, where a word's vector depends on its sentence, and sentence or image embeddings that represent whole inputs.
Embeddings are central to ML engineering: categorical features with millions of values become learned embedding tables in recommendation models; two-tower models embed users and items for fast retrieval; semantic search and retrieval for language models compare query and document embeddings with cosine similarity, using approximate nearest-neighbour indexes such as HNSW.
Practice. Embed a few thousand product descriptions with a pre-trained sentence model, build a nearest-neighbour index and measure recall at 10 on hand-labelled queries.
Stage 10 Production ML engineering and system design
Goal. Ship models as tested services and pipelines, design ML systems end to end, and monitor them in production.
ML system design Core
ML system design interviews ask you to design a whole system, such as a feed ranker, a fraud detector or a search engine. Use a fixed structure. Clarify the goal and constraints (users, scale, latency, what counts as success). Frame the ML problem: what is predicted, what is the label and where it comes from. Data and features. Model choice, starting with a baseline. Offline evaluation and metrics. Serving architecture (batch or online, retrieval then ranking, caching). Online evaluation with A/B testing. Monitoring and retraining.
Strong answers name trade-offs explicitly: freshness against cost, accuracy against latency, simplicity against small gains. General distributed systems knowledge (queues, caches, databases, load balancers) matters too; the System Design Roadmap covers it, and you can rehearse designs in system design practice.
Practice. Write a full design for a 'people you may know' feature following the structure above, including a diagram and a list of five failure modes.
APIs and model serving Core
Most models reach users through APIs. A typical online service loads the model once at start-up, validates input against a schema, computes or fetches features, runs inference and returns predictions with a model version. FastAPI with Pydantic is a common choice in Python; specialised servers such as TorchServe, Triton Inference Server or TensorFlow Serving add dynamic batching, multiple models per GPU and metrics.
Batch inference scores many rows on a schedule and writes results to a table; it is cheaper and simpler, and right whenever predictions can be a few hours old. Online inference answers each request within a latency budget. Streaming inference sits between them. Deployment patterns include shadow mode (new model runs but its output is not used), canary releases and A/B tests, with the previous model kept ready for rollback.
Practice. Serve a saved scikit-learn pipeline with FastAPI, add input validation and a health endpoint, and load-test it to find p95 latency.
Docker and reproducible environments Core
ML code is notoriously hard to reproduce: library versions, CUDA drivers and system packages all matter. Docker packages code, dependencies and runtime into an image that runs the same on a laptop, in CI and on a cluster. Learn Dockerfiles, layers and caching (copy dependency files and install before copying code), multi-stage builds to keep images small, GPU base images and environment variables for configuration.
Pin dependencies with a lock file, record the image tag with every trained model, and never bake secrets into images. The Docker Roadmap covers containers in depth; the MLOps Engineer page covers the wider platform.
Practice. Containerise your FastAPI model service with a multi-stage build, keep the image under 1 GB and run it with a mounted model file.
Data pipelines and training pipelines Core
A production model needs pipelines, not notebooks. A data pipeline extracts raw data, validates it, computes features and writes training sets; a training pipeline trains, evaluates against the current model and registers the new one if it passes. Orchestrators such as Airflow, Dagster, Prefect or Kubeflow Pipelines run these as directed graphs of steps with retries and schedules.
Good habits: make each step idempotent, so rerunning it gives the same result; version data snapshots and track experiments (parameters, metrics, code commit, data version) with a tool such as MLflow or Weights & Biases; validate data with checks on schema, ranges and null rates before training; and use a feature store or shared feature code so training and serving compute features identically.
Practice. Turn a notebook model into a pipeline with separate data, train, evaluate and register steps, each runnable from the command line, with MLflow tracking.
Testing ML code Recommended
ML code needs ordinary tests and some extra ones. Unit tests for feature functions with hand-computed expected values; tests for edge cases such as empty input, unseen categories and missing values. Shape tests for model code. A smoke test that runs training for a few steps on tiny data in CI. Invariance and directional tests on the model: changing a customer's name should not change a credit score, and a higher price should not increase predicted demand.
Before promoting a model, run evaluation gates: the new model must beat the current one on the agreed metric and must not regress on key slices or fairness checks beyond a tolerance.
Practice. Add pytest unit tests, a 30-second training smoke test and a train-versus-serve feature parity test to your pipeline project, and run them in CI.
Monitoring models in production Core
A deployed model can degrade without any error. Monitor four layers. Service health: latency, throughput, errors and resource use. Data quality: schema changes, null rates and out-of-range values in incoming features. Drift: data drift (input distributions shift, measured with population stability index or KS tests) and concept drift (the relation between inputs and target changes). Model quality: the real metric once labels arrive, which may take days or months.
Log every prediction with its inputs and model version so you can debug and build the next training set. Retrain on a schedule or when drift and quality triggers fire, and keep the last good model ready for fast rollback.
Practice. Simulate drift by shifting one feature in your test data, compute PSI for every feature and write an alert rule that would have caught it.
Large models, fine-tuning and efficiency Recommended
Many ML engineering roles now include working with large pre-trained models. Know the options in order of cost: use a pre-trained model as is; train a small head on frozen embeddings; parameter-efficient fine-tuning such as LoRA, which trains small adapter matrices; full fine-tuning; and training from scratch, which few teams need.
Efficiency skills are valued: mixed-precision training, gradient accumulation, gradient checkpointing, data-parallel and model-parallel training on several GPUs, and quantisation and batching for inference. Know how to estimate GPU memory: parameters, gradients and optimiser state together take several times the size of the weights during training. For serving and optimising large models specifically, see the Inference Engineer page.
Practice. Fine-tune a small pre-trained language model with LoRA on a classification dataset and compare accuracy, training time and memory with full fine-tuning.
Projects to build
Build these in order. Each one should end up in a public repository with a short README that explains your decisions.
- Tabular prediction with honest evaluationBeginner
Predict customer churn or loan default from a public dataset. Clean the data, build a scikit-learn pipeline, compare logistic regression, random forest and gradient boosting with cross-validation, and choose a decision threshold from stated business costs. Write a short report with a baseline, confusion matrix and SHAP plot.
Pandas · Scikit-learn pipelines · Model evaluation metrics · Explainable AI
- Algorithms from scratchBeginner
Implement linear regression, logistic regression, k-means, a decision tree, a two-layer neural network with backpropagation and the attention operation using only NumPy. Test each against a library implementation on the same data. This project doubles as ML coding interview practice.
NumPy · Linear algebra · Calculus · Backpropagation
- Image classifier with fine-tuningIntermediate
Collect or choose a small image dataset with a real use, such as plant diseases or product defects. Fine-tune a pre-trained CNN in PyTorch with augmentation, track experiments, analyse errors by class and export the model to ONNX. Report per-class metrics and examples of failures.
PyTorch · Convolutional neural networks · Transfer learning · Experiment tracking
- Semantic search serviceIntermediate
Embed a document collection with a pre-trained sentence model, build an approximate nearest-neighbour index and serve search through a FastAPI endpoint in Docker. Hand-label 50 queries and report recall at 10 against a keyword search baseline.
Embeddings · Transformers · APIs · Docker
- End-to-end recommender with monitoringAdvanced
Build a two-stage recommender on a public interactions dataset: candidate retrieval with embeddings, then a gradient boosting or neural ranker. Run it as a pipeline with data validation, training, evaluation gates and model registration, serve it behind an API, log predictions and add a drift dashboard. Write a design document explaining every trade-off.
ML system design · Feature engineering · Data pipelines · Monitoring models in production
Preparation plan
- Weeks 1–2Coding fundamentals and Python fluency
Solve two problems a day in coding practice, covering arrays, hash maps, strings and two pointers.
Revise NumPy and pandas by cleaning and summarising two public datasets without loops.
Write your two-minute project story and list target companies with the ML problems they likely solve.
- Weeks 3–4Maths and classical ML refresh
Rework gradient descent, the chain rule, Bayes' theorem and the bias-variance trade-off on paper.
Implement linear and logistic regression, k-means and a decision tree split from scratch.
Continue daily coding problems, adding heaps, trees and graphs.
- Weeks 5–6Evaluation, features and a tabular project
Build a leakage-free tabular project with time-based validation, a boosted tree model, SHAP explanations and a slice report.
Write answers to all metric and validation questions in this guide and say them aloud.
Practise SQL feature queries with window functions in SQL practice.
- Weeks 7–8Deep learning and transformers
Write a PyTorch training loop from memory; fine-tune a pre-trained CNN and a small transformer.
Implement attention and a two-layer backward pass in NumPy.
Review optimisers, normalisation and debugging steps for networks that will not train.
- Weeks 9–10Production and ML system design
Serve one project model with FastAPI in Docker, with tests, experiment tracking and a drift check.
Practise two ML system designs a week in system design practice under a 45-minute limit, then compare with a written checklist.
Read about general system design building blocks in the System Design Roadmap.
- Weeks 11–12Mock interviews and applications
Do at least four timed mocks: coding, ML coding, ML breadth and system design, ideally with a peer.
Prepare five behavioural stories and a deep-dive walkthrough of your best project.
Track weak areas in progress page and plan your remaining study with study plan.
Interview questions
Try to answer each question out loud before you open the answer.
Explain the bias-variance trade-off and how you would tell which problem a model has.Junior
Bias is error from a model too simple to capture the pattern; variance is error from a model so flexible it fits noise in the training data. I diagnose with learning curves. If training and validation errors are both high and close together, the model has high bias, so I add features, use a more flexible model or reduce regularisation. If training error is low and validation error much higher, it has high variance, so I add data, regularise, simplify or use bagging. The goal is the lowest validation error, not zero training error.
Your fraud model has 99.5% accuracy. Is it good?Junior
Not necessarily. If 0.5% of transactions are fraud, predicting 'not fraud' every time also gives 99.5% accuracy and catches nothing. I would look at the confusion matrix, precision and recall for the fraud class, and PR-AUC, which is more informative than ROC-AUC under heavy imbalance. Then I would pick a threshold from costs: a missed fraud costs the transaction amount, a false alarm costs a customer's annoyance and an analyst's time. I would also compare against the current rules engine as a baseline.
How does a random forest differ from gradient boosting?Junior
A random forest trains many deep trees independently on bootstrap samples with random feature subsets and averages them. This bagging reduces variance and is hard to overfit by adding trees. Gradient boosting trains shallow trees one after another, each fitted to the remaining errors of the ensemble, which reduces bias. Boosting is usually more accurate on tabular data but needs tuning: learning rate, depth and early stopping, since too many trees can overfit. Forests train in parallel; boosting is sequential across trees.
Walk me through backpropagation for a simple network.Mid
In the forward pass each layer computes z = Wx + b and an activation a = f(z), storing these values, and the last layer's output goes into the loss. Backpropagation applies the chain rule from the loss backwards. At the output, I compute the derivative of the loss with respect to the output; for softmax with cross-entropy this simplifies to prediction minus target. For each layer, the weight gradient is the incoming gradient times the layer's input transposed, and the gradient passed to the previous layer is the weights transposed times the incoming gradient, multiplied by the activation's derivative. An optimiser then updates the weights.
Your validation loss stops improving after two epochs while training loss keeps falling. What do you do?Mid
That is overfitting. First I check the basics: that validation data is processed the same way and that there is no leakage or duplication making training easy. Then I try, roughly in this order: early stopping and keeping the best checkpoint, data augmentation, weight decay and dropout, a smaller model or freezing more layers of a pre-trained backbone, a lower learning rate with a schedule, and more or cleaner data. I change one thing at a time and track each run so I know what helped.
What is data leakage? Give an example you might miss.Mid
Leakage is when training features contain information that will not be available at prediction time, so offline scores are inflated. An obvious case is a feature derived from the label. Subtle cases: a 30-day aggregate computed over a window that extends past the prediction date; fitting a scaler or target encoder on the whole dataset before splitting; random splits when the same customer appears in train and test; or a 'cancellation reason' field filled in only after a customer churns. I prevent it with time-based splits, pipelines that fit preprocessing inside each fold, and suspicion of any feature that dominates importance.
How do transformers handle word order, and why does attention scale poorly with sequence length?Mid
Self-attention on its own ignores order, since it treats the input as a set. Transformers add positional information: fixed sinusoidal or learned position embeddings added to tokens, or relative schemes such as rotary embeddings applied inside attention. Attention compares every token with every other token, so the score matrix has n squared entries for n tokens, and both compute and memory grow quadratically. Engineering responses include memory-efficient attention kernels, sliding-window or sparse attention, and caching keys and values during generation so earlier tokens are not recomputed.
How would you handle a heavily imbalanced classification problem?Mid
I start by choosing an evaluation metric that reflects the minority class, such as PR-AUC or recall at a fixed precision, and stratified splits. On the modelling side, options are class weights in the loss, undersampling the majority class (good for speed with large data), oversampling or synthetic methods such as SMOTE (used with care, inside folds only), and focal loss for neural networks. Often the biggest gain is choosing the threshold properly. If I resample, I recalibrate probabilities afterwards, because resampling distorts them.
What is training-serving skew and how do you prevent it?Mid
It is any difference between the data or feature logic a model saw in training and what it receives in production. Causes include features reimplemented in another language for serving, different handling of missing values, stale features in the online store, and time-zone differences. Prevention: share one feature implementation for both paths or use a feature store, log the features actually served and train on those logs where possible, add a parity test comparing training and serving features for the same raw input, and monitor feature distributions in production against training.
Design a system that recommends videos on a home feed.Senior
I clarify the goal, for example long-term watch time with satisfaction guardrails, plus scale and latency. I use a multi-stage design. Candidate generation retrieves a few hundred items from millions with several sources: a two-tower embedding model with an approximate nearest-neighbour index, recent creators the user follows and trending items. A ranking model, a deep network or boosted trees, scores candidates on predicted engagement using user, item and context features. A re-ranking step applies diversity, freshness and policy rules. Labels come from logged impressions and watches. I evaluate offline with recall at k and NDCG, then run an A/B test. I monitor drift and feedback loops, and add exploration for new content.
A model's online A/B test is flat even though offline AUC improved by two points. Why might that be?Senior
Several possible causes. The offline metric may not match the online goal: better ranking of items users would not have seen anyway. There may be training-serving skew or stale features, so the production model is not the one evaluated. Offline evaluation may be biased by logged data from the old model's choices. The gain may sit in segments that see little traffic, or the test may be underpowered. I would check feature parity and prediction logs first, then slice the offline gain by segment, then confirm the test's power and run duration.
How do you monitor a model whose labels arrive 60 days later?Senior
I cannot wait 60 days to learn it broke, so I use proxies. I monitor input data quality and feature drift against training, the distribution of predicted scores, and business proxies that arrive early, such as early repayment behaviour for a credit model. I compare models on the same traffic, for example a shadow model. When labels arrive, I compute the real metric by cohort and backfill dashboards. I also keep a small, fast labelling path where possible, such as manual review of a sample, to get earlier ground truth.
How would you speed up inference for a large neural network that misses its latency target?Senior
First I profile to find where time goes: preprocessing, network transfer, model compute or post-processing. For compute, options are dynamic batching on the server, mixed precision or 8-bit quantisation, compiling with ONNX Runtime or TensorRT, distilling into a smaller model, pruning, and caching results for repeated inputs. For architecture, I can split into a cheap first stage that filters candidates and a heavy second stage on fewer items. I check accuracy after every change against an agreed tolerance, and look at p99 latency, not only the mean.
Tell me about a model that did not work. What did you learn?Mid
A strong answer names a specific project, explains why it failed honestly (for example, the label was a poor proxy for what the business cared about, or offline gains did not survive an A/B test), what you did when you found out, and what you changed in your process, such as agreeing the online metric before training or adding a shadow phase. Avoid blaming others. Interviewers look for ownership, scientific honesty and a concrete change in behaviour.
A product manager wants a model shipped this week, but your evaluation shows it is worse for one region. What do you do?Senior
I share the finding quickly with numbers, not just a warning: how much worse, for how many users, and the likely cause. Then I offer options rather than a refusal: ship to the regions where it is better and keep the current model for the affected one, ship behind a flag with a short A/B test and a clear stop rule, or delay a week to fix the cause. I document the decision and who made it. The product manager owns the trade-off; my job is to make the risk visible and give workable choices.
Common mistakes
- Jumping to deep learning on tabular data; fit a simple baseline and a gradient boosting model first, and only go further if they fall short.
- Using random splits on time-ordered or grouped data; split the way the model will be used in production.
- Fitting scalers, encoders or feature selection on the full dataset; put all preprocessing inside a pipeline fitted per fold.
- Reporting accuracy on imbalanced problems; use precision, recall, PR-AUC and a threshold chosen from costs.
- Skipping the maths and treating libraries as black boxes; be able to derive gradient descent and backpropagation for simple models.
- Building portfolio projects that end in a notebook; ship at least one model as a tested service with a pipeline and monitoring.
- Neglecting the standard coding round; ML engineers are usually held to the same algorithms bar as software engineers, so practise daily.
- Tuning hyperparameters for days before checking data quality and labels; audit data first, because it usually limits performance more.
Ready-for-interview checklist
- I can explain the bias-variance trade-off and diagnose it from learning curves.
- I can derive gradient descent for linear and logistic regression and backpropagation for a two-layer network.
- I can implement k-means, logistic regression and an evaluation metric from scratch in NumPy.
- I can prepare data without leakage and choose a split that matches production use.
- I can choose metrics for imbalanced classification, regression and ranking, and set a threshold from costs.
- I can explain how trees, random forests and gradient boosting work and tune them.
- I can write a PyTorch training loop from memory and debug a network that will not train.
- I can explain convolutions, LSTMs, self-attention and transformers, and when to fine-tune a pre-trained model.
- I can serve a model behind an API in Docker with tests and input validation.
- I can describe how to monitor a model for drift and quality and when to retrain.
- I can run a 45-minute ML system design discussion from problem framing to online evaluation.
- I can solve medium-level coding problems in Python in under 30 minutes.
- I can tell three stories about projects, including one failure, with measurable outcomes.
Where this role leads
Senior and staff ML engineer: own larger systems such as ranking or fraud platforms and set modelling direction for a product area.
MLOps Engineer: specialise in the platform that trains, deploys and monitors models for many teams.
AI Engineer or Inference Engineer: build products on large language models, or specialise in making large models fast and cheap to serve.
Applied or research scientist: move towards new methods and publications, usually with deeper maths and a postgraduate degree helping.
Engineering Manager: lead an ML team, balancing technical direction with hiring and delivery.
Related roadmaps
- Python RoadmapSyntax to packaging: data model, typing, async, testing.
- Python for Data Analysis RoadmapNumPy, pandas, cleaning, visualisation and notebooks.
- SQL RoadmapQueries, joins, window functions, indexes and transactions.
- Data Structures and Algorithms RoadmapFrom arrays to graphs and DP, organised by interview pattern.
- System Design RoadmapScalability, caching, queues, consistency and the classic designs.
- Docker RoadmapImages, containers, networking, volumes, Compose and security.
FAQ
How long does it take to become a machine learning engineer?
From zero, most people need nine to fifteen months of steady study at around twelve hours a week, because the role combines programming, maths, ML and production engineering. Software engineers who already code well often get there in four to six months by focusing on maths, ML and evaluation. Data scientists usually need to strengthen software engineering, coding interviews and deployment. A portfolio with at least one deployed, monitored project shortens the job search noticeably.
How much maths do I need for machine learning engineering?
You need working knowledge, not research depth: linear algebra (vectors, matrices, matrix multiplication, eigenvectors at a conceptual level), calculus (derivatives, gradients, the chain rule), probability (Bayes' theorem, distributions, expectation) and statistics (confidence intervals, hypothesis tests). You should be able to derive gradient descent for linear regression and explain backpropagation. The maths stage on this page covers what interviews expect.
What is the difference between a data scientist and an ML engineer?
A data scientist focuses on analysis, experimentation and building models to answer questions or prove value, often in notebooks. An ML engineer focuses on making models run reliably in production: pipelines, serving, testing, monitoring and scale. The roles overlap heavily, and titles vary between companies. If you enjoy software engineering and systems as much as modelling, ML engineering is the closer fit; see the Data Scientist page for the other side.
Is machine learning engineering still worth learning with large language models everywhere?
Yes. Large language models have added work rather than removed it: someone has to fine-tune, evaluate, serve and monitor them, and most company prediction problems such as fraud, ranking, forecasting and pricing still run on models trained on the company's own data. The fundamentals on this page, evaluation, data quality, training and serving, are exactly what working with large models requires.