Linear Prediction
Easy
~12 min
code completion
Linear Prediction
A linear model makes predictions with a simple dot product plus a bias:
where:
This is the forward pass of linear regression.
Your task:
Implement linear_predict(X, weights, bias) that returns the prediction vector of shape (m,).
Example Tests
2x2 matrix with equal weights and bias
Input: {"X":[[1,2],[3,4]],"bias":1,"weights":[0.5,0.5]}
Expected: [2.5,4.5]
3 samples, integer weights, no bias
Input: {"X":[[1,0],[0,1],[1,1]],"bias":0,"weights":[2,3]}
Expected: [2,3,5]
Negative weights
Input: {"X":[[2,3]],"bias":5,"weights":[-1,2]}
Expected: [9]