1. Model Definition
Logistic regression is used to model the probability of a binary outcome.
The prediction is defined as:
Where:
- is the sigmoid function
- and are parameters
- is the input of the -th training example
The sigmoid function ensures that the output is between 0 and 1.
2. Training Objective
Given a training set of labeled examples:
- , where
The objective is to find parameters and such that:
The superscript denotes the index of the training example.
3. Loss Function
The loss function measures the error for a single training example.
Logistic regression uses the following loss function:
This function is chosen instead of squared error because it leads to a convex optimization problem, which is easier to optimize.
4. Behavior of the Loss Function
- If : Minimizing loss requires
- If : Minimizing loss requires
5. Cost Function
The cost function evaluates the model over the entire training set.
Expanded form:
6. Optimization Goal
Training logistic regression involves:
- Minimizing the cost function
- Using optimization methods such as gradient descent
7. Key Distinction
- Loss function: applied to a single training example
- Cost function: average of losses over all training examples
