Implement Batch Gradient Descent for Linear Regression
AmazonData Scientist · Technical ScreenLast updated
Amazon data scientist machine learning prompt on writing batch gradient descent pseudocode for linear regression, including MSE loss, vectorized gradients, parameter updates, stopping criteria, and implementation checks.
Scenario
Building a linear regression model from scratch; parameters are optimized through batch gradient descent.
Question
Write Python-style pseudocode for batch gradient descent that minimizes mean-squared error for linear regression. Explain briefly what each step in your pseudocode does.
Hints
Cover initialization, prediction, error, gradient, parameter update, loop/stop conditions.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.