PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Machine Learning/Capital One

Evaluate OutlierHandler Class for Code Quality and Testing

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's competence in machine-learning data preprocessing, scikit-learn-style transformer API design, unit testing, and code quality assessment including PEP-8 and maintainability concerns.

  • medium
  • Capital One
  • Machine Learning
  • Data Scientist

Evaluate OutlierHandler Class for Code Quality and Testing

Company: Capital One

Role: Data Scientist

Category: Machine Learning

Difficulty: medium

Interview Round: Onsite

##### Scenario Code-review of two Python preprocessing components: an OutlierHandler class and three Imputer classes ##### Question Give a high-level summary of what the OutlierHandler class does. Why is it beneficial to separate `fit` and `transform` into two methods in this context? Point out any coding-style or maintainability issues you observe in the file (naming, docstrings, magic numbers, etc.). Write the single most critical unit test you would add for the OutlierHandler. For the three imputation classes, describe their overall purpose and identify at least two style problems (e.g., use of `from numpy import *`). ##### Hints Relate your answers to the scikit-learn transformer API, unit-testing best practices, and PEP-8.

Quick Answer: This question evaluates a candidate's competence in machine-learning data preprocessing, scikit-learn-style transformer API design, unit testing, and code quality assessment including PEP-8 and maintainability concerns.

Related Interview Questions

  • Deep-dive XGBoost handling and overfitting - Capital One (medium)
  • Build House Price Model Responsibly - Capital One (easy)
  • Design robber detection from surveillance video - Capital One (easy)
  • How would you design delay and watchlist models? - Capital One (medium)
  • Explain core ML concepts and lifecycle - Capital One (medium)
Capital One logo
Capital One
Jul 12, 2025, 6:59 PM
Data Scientist
Onsite
Machine Learning
62
0

Code Review: OutlierHandler and Imputer Classes

Context

You are given a Python module that implements one OutlierHandler class and three Imputer classes for preprocessing tabular data. The classes appear to be intended for use in machine-learning pipelines (e.g., scikit-learn style), but the code has mixed style and testing coverage.

Assumptions to make the question self-contained:

  • OutlierHandler detects outliers per feature using a rule such as IQR capping (Q1 − 1.5×IQR, Q3 + 1.5×IQR) or z-score thresholds and caps or replaces outliers during transform.
  • Each Imputer learns a statistic on fit (e.g., mean/median/mode/constant) and fills missing values during transform.

Tasks

  1. Provide a high-level summary of what the OutlierHandler class does.
  2. Explain why separating fit and transform into two methods is beneficial in this context.
  3. Identify coding-style and maintainability issues in the file (naming, docstrings, magic numbers, etc.).
  4. Propose the single most critical unit test you would add for OutlierHandler.
  5. For the three imputation classes, describe their overall purpose and identify at least two style problems (e.g., use of from numpy import * ).

Hints: Relate your answers to the scikit-learn transformer API, unit-testing best practices, and PEP-8.

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Machine Learning•More Capital One•More Data Scientist•Capital One Data Scientist•Capital One Machine Learning•Data Scientist Machine Learning
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.