Explain Shell Script Line-by-Line for Data Science Workflows
Company: Capital One
Role: Data Scientist
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Overview: This question evaluates familiarity with shell scripting for reproducible data-science workflows, Python object-oriented design including transformer patterns (fit/transform separation), outlier detection and imputation strategies, code-style critique, and unit testing competency.
Constraints
- 0 <= len(ops) <= 100000
- Each op is a non-empty string
- Format must be exactly "Component.method" with one dot
- Component characters allowed: [A-Za-z0-9_]
- Allowed methods: fit, transform, fit_transform, reset
- Time complexity should be O(n)
- Space complexity should be O(k) where k is the number of distinct components
Hints
- Track per-component fitted state in a dictionary.
- Treat fit_transform as performing both fit and transform in one step.
- Reset should clear a component’s fitted state.
- Reject any operation that does not match the exact format or contains an unknown method.