- TensorFlow Machine Learning Projects
- Ankit Jain Armando Fandango Amita Kapoor
- 184字
- 2025-02-21 07:26:41
Logistic regression for binary classification
For binary classification, the model function ϕ(z) is defined as the sigmoid function, which can be described as follows:

The sigmoid function transforms the y value to be between the range [0,1]. Thus, the value of y=ϕ(z) can be used to predict the class: if y > 0.5, then the object belongs to 1, otherwise the object belongs to 0.
The model training means to search for the parameters that minimize the loss function, which can either be the sum of squared errors or the sum of mean squared errors. For logistic regression, the likelihood is maximized as follows:
However, as it is easier to maximize the log-likelihood, we use the log-likelihood (l(w)) as the cost function. The loss function (J(w)) is written as -l(w), and can be minimized by using optimization algorithms such as gradient descent.
The loss function for binary logistic regression is written mathematically as follows:

Here, ϕ(z) is the sigmoid function.