Your question is Linear Regression From Scratch. 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.
Write a function that fits a univariate linear regression model from scratch. Given training data x and y, return the slope and intercept of the best-fit line y = m*x + b using least squares.
Your function must not use machine learning libraries. You may use only basic Python and math if needed.
Implement:
fit_linear_regression(x, y)
x: list of numeric feature valuesy: list of numeric target values(m, b) where m is the slope and b is the interceptUse the closed-form least squares solution. Assume x and y have the same length and contain at least 2 points.
def fit_linear_regression(x, y):