Logistic Regression Prediction
MediumMachine LearningMath
Description
Given a weight vector w, a feature vector x of the same length, and a bias b, return the logistic regression prediction: the sigmoid of (w · x + b), where sigmoid(z) = 1 / (1 + e^(-z)). Round the result to 4 decimal places.
Examples
Input:
[1,-1], [2,3], 0Output:
0.2689Explanation:
The model forms the weighted sum of the inputs plus the bias, then squashes that score through the sigmoid to produce a probability between 0 and 1.
Input:
[1,1], [1,1], 0Output:
0.8808Explanation:
The model forms the weighted sum of the inputs plus the bias, then squashes that score through the sigmoid to produce a probability between 0 and 1.
Input:
[2,-1], [1,1], 0Output:
0.7311Explanation:
The model forms the weighted sum of the inputs plus the bias, then squashes that score through the sigmoid to produce a probability between 0 and 1.
Constraints
- •
1 ≤ length ≤ 10³