Back to problems

Linear Regression from Scratch

Algorithm · Capital One · Medium

Requirements Create LinearRegression.fit(X, y) and LinearRegression.predict(X) with NumPy alone; do not use scikit-learn in the implementation. Provide both a normal-equation implementation, $$\theta = (X^{T}X)^(-1) X^{T}y$$, and an iterative gradient-descent implementation, since interviewers commonly request the two consecutively. Account for an intercept, either by adding a leading column of ones to X or by maintaining an independent bias value. Be ready to explain…

Checking your access…