What You Will Learn in This Section
- Understanding the sigmoid function
- The necessity of the sigmoid function
Why Is the Sigmoid Function Used in Logistic Regression?
In classification problems, the dependent variable has two possible values: 0 and 1. The sigmoid function takes any numerical input and maps it to a value between \( [0,1] \), allowing us to predict the class of data points based on its output. We can determine class = 1 when the sigmoid value exceeds a chosen threshold; otherwise, we assign class = 0. A common threshold choice is 0.5, meaning: \begin{align} class = \left\{ \begin{array}{cl} 1 & \text{if} \ \text{sigmoid}(x) \geq 0.5 \\ 0 & \text{if} \ \text{sigmoid}(x) < 0.5 \end{array} \right. \end{align} However, the threshold can be treated as a tunable hyperparameter. Instead of 0.5, we can set any other threshold based on specific requirements. For example, we may decide that a data point is classified as class = 1 only if the sigmoid score is greater than 0.8; otherwise, it is classified as 0.