Your question is Implement Gradient Descent in Python. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
DeepSig needs a lightweight baseline for predicting a continuous signal-quality value from numerical radio features. Implement batch gradient descent for a linear regression model without using machine learning libraries.
Given a feature matrix X, target values y, a learning rate, and a fixed iteration count, learn one weight per feature and an intercept. Initialize all parameters to zero. On every iteration, compute predictions for the full batch, calculate the mean squared error gradients, and update all parameters simultaneously.
Implement gradient_descent(X, y, learning_rate, iterations). X is a non-empty list of n rows, each containing d numeric features. y is a list of n numeric targets. Return a dictionary with keys weights and bias, where weights is a list of d floats and bias is a float.
Use these gradients:
dw[j] = (2 / n) * sum((prediction[i] - y[i]) * X[i][j])db = (2 / n) * sum(prediction[i] - y[i])Updates must use the parameters from the start of the iteration.
def gradient_descent(X, y, learning_rate, iterations):