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], 0
Output:0.2689
Explanation:

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], 0
Output:0.8808
Explanation:

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], 0
Output:0.7311
Explanation:

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³

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.