The above is a much better fit when compared. The curve of the graph above is called the Sigmoid or Logit function. The basic idea is, it is a mathematical function having a characteristic that can take any real value and map it to between 0 to 1 shaped like the letter “S”. The sigmoid function is also called a logistic function.
Formula:
\(sigmoid(z) = \frac{1}{1 + e^{-z}}\)
where, e = Euler’s number ~ 2.7182
So, when the value of z tends to positive infinity then the predicted value of y will become 1 and when it tends to negative infinity then the predicted value of y will become 0. If the outcome/value of the sigmoid function is more than 0.5 then we classify that label as a positive class and if it is less than 0.5 then we label it to a negative class.