Linear Regression from Scratch
Asked at Capital One · Coding & Leetcode-style Questions · Difficulty: Medium · Last asked Jan 19, 2026
Fit a straight line (or hyperplane) to data. Given rows of numeric features and a numeric target, find the coefficients that minimise the mean squared error, then use them to predict. Write it in pure Python (standard library only, no NumPy or scikit-learn), in two ways: with the closed-form normal equation, and with gradient descent.
Loading the problem…
More Capital One interview questions
- Implement Top-P (Nucleus) Sampling
- Design a Customer-Service Chatbot for Capital One
- Capital One Power Day Behavioral (STAR)
- Amusement Park Profitability Case
- MLE Deployment, Monitoring & Latency Optimisation
- Reliable Account Balance Service and Cross-Region Event Platform