Loading...
Implement the prediction step of logistic regression.
Given a feature matrix X (without bias), a weight vector w, and a bias b, compute the probability for each sample using:
P(y=1∣x)=σ(x⋅w+b)=1+e−(x⋅w+b)1
Then classify each sample: if P≥0.5, predict 1; otherwise predict 0.
Return a list of tuples [(probability, prediction), ...] with probabilities rounded to 4 decimal places.
X = [[1, 2], [3, 4], [-1, -2]] w = [0.5, -0.3] b = 0.1
[(0.5, 1), (0.5987, 1), (0.5498, 1)]