Classification changes the prediction we want to make. The discussion moves from fitting values to estimating class probabilities and controlling overfitting.
Why logistic regression is a classifier
Regression: act of going back to previous state
We are still modelling relationship between independent and dependent variables, instead of predicting continuous outcome, we are predicting probability of binary outcome



If we choose different z, we can map complex decision boundries


Logistic loss
Squared error function give non convex cost function

Tou we use Logistic loss function:

Cost function is average loss of all training examples

We can simplify above stepwise function into this:


Therefore cost function looks like this:


Bias and variance
- Variance: how much models predictions vary when its trained on different subsets training data, measure of spread around mean of data. Its the error introduced because model is too sensitive to fluctuations in training data, high variance can lead to overfitting
- Bias: error introduced by approximating real-world problem. High bias can lead to underfitting, where model doesn’t captures the underlying patterns of data well
Goal is to find balance between bias and variance
Highly biased ML model makes wrong assumptions leading to underfitting of training data
If our ML model has high bias, it might make overly simplistic assumptions such as:
- All emails with word 'free' are spam
- All emails from unknown senders are spam
- All emails with attachments are not spam
Model is biased towards specific features/patterns in data and makes predictions solely on those biases, rather than accurately capturing true relationship between features and target variable

Model with low bias is not biased towards overly simplistic assumptions. A very low bias can introduce overfitting
When we say ML model has high variance(overfitting), it means model's predictions vary significantly with different training datasets
When training a ML model, we use specific dataset to make predictions.
If we train same ML model multiple times using different subsets of avaliable training data, we might obtain different versions of model each time
Model with high variance exhibits significant sensitivity to these variations in training data. It means predictions made by model can vary considerably depending on which subset of training data was used to train it

Reducing overfitting
- Collect more data
- Select features
- Reduce size of parameters
Regularization
Make some w's nearer to zero
If we were to map the higher order polynomial onto dataset, we would get obnoxious mapping. New cost function:

The regularization term adds a penalty proportional to sum of squares of weights
During optimization(gradient descent), this penalty encourages algorithm to find a solution where weights are smaller, this is because larger weights increase the cost, and minimizing the cost function will shrink the weights
Regularized linear regression

Regularized logistic regression
