In our last lesson, we focused on getting your numerical data into the right shape and scale for your models. Now, we'll address an equally, if not more, common and critical challenge in real-world data pipelines: what to do when your data isn't all there. Missing values are a fact of life in any data-driven field, especially in fintech where data might be incomplete due to user input errors, system failures, or privacy considerations.
This lesson directly tackles the learning outcome of applying appropriate imputation strategies and, crucially for your interview, explaining the trade-offs. We will explore why data goes missing, examine a range of imputation techniques from the simple to the sophisticated, and build a framework for choosing the right method for the job. By the end, you will be able to confidently discuss how to handle missing data, demonstrating a practical and nuanced understanding of data preprocessing.
Why is the Data Missing? Understanding the Mechanisms
Before we jump into solutions, it's essential to understand the nature of the missingness. In an interview, discussing why data might be missing before stating how you'd fix it demonstrates a deeper, more principled approach. There are three main categories.
Data Imputation Techniques in ML - GeeksforGeeks
This article from GeeksforGeeks provides a concise definition of the three types of missing data.
Read the introductory section, focusing on the descriptions of the three categories.
To solidify these concepts, let's look at a visual representation.

Understanding this classification is key because it influences which imputation strategies are statistically valid. While we often don't know the true mechanism, having this framework helps you reason about the potential biases your chosen method might introduce. For example, if you suspect the data is MNAR, simply dropping the rows could introduce significant bias into your model.
Strategy 1: The Simple Approaches
The most straightforward methods for handling missing data involve either removing the problematic data or filling it in with a simple statistical value. While basic, these are important to know as they serve as common baselines.
Complete Case Analysis (Deletion)
The simplest strategy of all is to just remove any rows (or columns) that contain missing values.
Top 5 Interview Questions on Missing Value Imputation -
This article from Analytics Vidhya, framed as interview questions, is perfect for our goal. It explains the pros and cons of this direct approach.
Read the section titled What is Complete Case Analysis. Pay attention to the rule of thumb regarding when this might be acceptable.
The major trade-offs with CCA are:
- Pro: Simple and fast to implement.
- Con: Can lead to significant data loss if many rows have at least one missing value. It can also introduce bias if the missing values are not MCAR.
Mean, Median, and Mode Imputation (Univariate Imputation)
Instead of deleting data, we can fill in the gaps. This is called imputation. The simplest form is univariate imputation, where we only use the information from the column containing the missing value.
- Mean Imputation: Replace missing values with the average of the column.
- Median Imputation: Replace missing values with the median of the column.
- Mode Imputation: Replace missing values with the most frequent value in the column (primarily for categorical data).
Your previous lesson on scaling and transformations highlighted the sensitivity of the mean to outliers. The same logic applies here, making median imputation a more robust choice for skewed numerical data, which is common in fintech (e.g., income, transaction value).
Top 5 Interview Questions on Missing Value Imputation -
Let's return to the Analytics Vidhya article for a clear explanation of the mean vs. median trade-off.
Read the section answering the question: Which Imputation is better for numerical data with outliers.
Here's a visual summary of the simple strategies and their main drawbacks.

The trade-offs for these simple statistical imputations are:
- Pros: Easy to implement and computationally cheap.
- Cons: They distort the original variance and covariance of the data. By filling all missing values with the same number, you are artificially reducing the feature's variance and potentially weakening its relationship with other features.
Strategy 2: The Advanced Approaches (Multivariate Imputation)
More sophisticated techniques use relationships between variables to make more intelligent guesses for the missing values. This is called multivariate imputation.
Top 5 Interview Questions on Missing Value Imputation -
This article clearly defines the difference between univariate and multivariate approaches.
Read the short section on the difference between the two types.
K-Nearest Neighbors (KNN) Imputation
The intuition here is that a data point's missing value can be estimated from its "neighbors"—other data points that are similar based on their observed features. The algorithm finds the k most similar rows and uses their values in the target column (e.g., by averaging them) to fill in the blank.
Given your background, you can think of this as applying the core logic of the KNN algorithm to a data imputation problem. A crucial prerequisite, linking back to our last lesson, is that features must be scaled before applying KNN Imputer, as it relies on distance calculations.
Iterative Imputation (MICE)
Iterative imputation, also known as Multivariate Imputation by Chained Equations (MICE), is one of the most powerful methods. It works by modeling each feature with missing values as a function of the other features.
Here's the process at a high level:
- Make an initial guess for the missing values (e.g., using mean imputation).
- Take the first column with missing values. Treat it as the target variable
yand the other columns as featuresX. - Train a regression model (like
BayesianRidgeorRandomForestRegressor) on the rows where this column is not missing. - Use the trained model to predict the missing values in that column.
- Repeat this process for every column with missing values, iterating multiple times. The predictions will become more and more accurate as the imputed values in other columns improve.
This approach essentially turns an imputation problem into a series of predictive modeling tasks, leveraging the full correlational structure of the data.
For a practical demonstration of how to implement KNNImputer and IterativeImputer using scikit-learn, the following video from Data School is excellent.
Impute missing values using KNNImputer or IterativeImputer
This video provides a clear, code-first walkthrough of KNN and Iterative imputation.
First, watch the demonstration of KNNImputer. Then, watch the explanation and implementation of IterativeImputer. Notice how IterativeImputer is essentially a full machine learning process embedded within your preprocessing pipeline.
Articulating the Trade-Offs for Your Interview
Your ability to choose the right strategy and defend that choice is what will impress an interviewer. Here is a summary of the trade-offs to help you structure your thoughts.
| Method | When to Use | Pros | Cons |
|---|---|---|---|
| Complete Case Analysis | Small amount of missing data (<5%) and it's likely MCAR. | Simple, fast. | Can cause significant data loss and bias. |
| Mean/Median/Mode | As a quick baseline; when speed is critical. Median is preferred with outliers/skew. | Computationally cheap, easy to implement. | Distorts variance and covariance. Ignores relationships between features. |
| KNN Imputation | Data has clear patterns/correlations. The dataset is not excessively large. | More accurate than simple methods; uses feature relationships. | Computationally more expensive. Requires feature scaling. Sensitive to the choice of k. |
| Iterative Imputer (MICE) | Accuracy is paramount and computational cost is acceptable. Missingness is likely MAR. | Often the most accurate method. Preserves relationships between variables well. | Computationally intensive and complex to implement and tune. |
For a final review that frames these concepts perfectly for a data science interview context, I recommend watching the following video.
Dealing with Missing Values in Machine Learning: Easy Explanation for Data Science Interviews
This video by Emma Ding is tailored specifically for interview preparation and provides a great summary of the concepts we've discussed.
Watch the following segments to consolidate your understanding: Types of missing data Deletion and Univariate Imputation Multivariate Imputation A summary of the trade-offs
Conclusion
You now have a comprehensive toolkit for one of the most fundamental data preprocessing tasks. Handling missing data isn't just about filling in cells; it's about making reasoned choices that preserve the integrity of your dataset and the validity of your model. In a fintech setting, where decisions about fraud or credit risk can have major consequences, demonstrating this careful and principled approach is a significant strength.
Key Takeaways:
- Diagnose First: Always start by considering why data might be missing (MCAR, MAR, MNAR) as this informs your strategy.
- Simple vs. Sophisticated: Simple methods (deletion, mean/median) are fast baselines but distort data distributions. Sophisticated methods (KNN, Iterative Imputation) are more accurate by using inter-feature relationships but are computationally expensive.
- The Core Trade-off: The choice of an imputation method is a trade-off between computational cost, implementation complexity, and the potential for introducing bias versus preserving the statistical properties of your data.
- No Free Lunch: No single method is always best. The right choice depends on the dataset, the missing data mechanism, the specific model you intend to use, and your computational constraints.
In our next lesson, we'll continue our journey through data preprocessing by tackling another common challenge: how to convert categorical variables into a numerical format that machine learning models can understand, using techniques like one-hot and label encoding.