← Capital One Interview Insights

Capital One·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
Jul 2026

Summary

Capital One data scientist tech round where they handed me three imputation class implementations and asked me to tear them apart. Code review style, which I wasn't fully expecting going in.

Questions Asked (2)

Q1

Given three imputation class implementations covering mean, median, and mode substitution, what problems or risks do you see in the code?

Technical Trade-offsRoot Cause AnalysisAlgorithms & Data Structures
Author's notes

I started picking at surface stuff like missing null checks and then kind of stalled.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the context: imputation is a preprocessing step, and the choice of method depends on data type, distribution, and missingness mechanism. Then, systematically evaluate each implementation for statistical validity, computational efficiency, and potential to introduce bias or distort relationships. Finally, discuss trade-offs and suggest improvements or alternatives.

Pro tip: Emphasize that imputation should be done after train-test split to avoid data leakage, and mention that mean/median/mode imputation assumes missingness is completely at random (MCAR), which is often unrealistic.

1. Clarify assumptions and context

Discuss the missingness mechanism (MCAR, MAR, MNAR) and how mean/median/mode imputation assumes MCAR, which can bias results if violated. Also note that these methods are only applicable to certain data types (e.g., mode for categorical, mean/median for numerical).

2. Evaluate statistical impact

Analyze how each method affects the distribution: mean imputation reduces variance and can distort correlations; median is more robust to outliers but still reduces variance; mode can create artificial peaks for categorical variables.

3. Assess implementation risks

Check for data leakage if imputation is done before train-test split, and consider computational efficiency for large datasets. Also, look for handling of edge cases like all-missing columns or multiple modes.

4. Consider alternatives and trade-offs

Compare with more sophisticated methods like regression imputation, KNN, or multiple imputation, and discuss when simple methods might be acceptable (e.g., small missing rate, baseline models).

5. Summarize recommendations

Provide a balanced conclusion: mean/median/mode are simple and fast but can introduce bias and underestimate uncertainty; recommend using them cautiously and validating their impact on model performance.

Key Points to Mention

  • Data leakage: imputation must be fit on training data only and applied to test data.
  • Reduction in variance and distortion of correlations due to mean/median imputation.
  • Mode imputation can create artificial categories and is only for categorical variables.
  • Assumption of MCAR and the risk of biased estimates if data are MAR or MNAR.
  • Impact on downstream models: may lead to overfitting or underestimated error rates.
  • Alternatives: multiple imputation, model-based imputation, or using algorithms that handle missing values natively.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

How would you refactor these imputation classes to be more robust and reusable, and what design patterns or interface conventions would you apply?

System DesignTechnical Trade-offsData Modeling
Author's notes

They wanted concrete suggestions, not just 'add inheritance.' I talked about a shared base class and sklearn-compatible fit/transform methods, which landed okay.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the current imputation classes and their limitations, then propose a refactoring strategy that abstracts common functionality into a base class or interface, and introduces design patterns like Strategy or Factory to make the code more modular and testable. Emphasize how this improves robustness, reusability, and maintainability, and tie it back to real-world data science workflows at Capital One.

Pro tip: Mention that you would write unit tests for each imputation strategy and use dependency injection to make the classes easily testable and configurable, showing you care about production-quality code.

1. Identify current issues

Discuss the problems with the existing imputation classes, such as code duplication, lack of flexibility, and difficulty in adding new imputation methods.

2. Define a common interface

Propose an abstract base class or interface (e.g., Imputer) that defines a common method like impute() and fit(), ensuring all imputation strategies adhere to a consistent contract.

3. Apply design patterns

Suggest using the Strategy pattern to encapsulate different imputation algorithms and the Factory pattern to instantiate the appropriate imputer based on configuration or data characteristics.

4. Enhance robustness and reusability

Explain how to add input validation, handle missing data edge cases, and make the classes configurable via parameters or a config object, promoting reuse across projects.

5. Discuss testing and integration

Mention writing unit tests for each imputer and integrating with existing pipelines, possibly using dependency injection to swap implementations easily.

Key Points to Mention

  • Single Responsibility Principle and Open/Closed Principle
  • Strategy pattern for interchangeable imputation algorithms
  • Factory pattern for creating imputers based on configuration
  • Abstract base class or interface to enforce consistent API
  • Input validation and handling of edge cases (e.g., all missing values)
  • Unit testing and dependency injection for testability

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.