Solved – What does Penalize a learning algorithm mean in Machine Learning

bias-variance tradeoffmachine learningregression

I am new to Machine Learning and have taken Andrew Ng's course on Machine Learning.

In one of the Logistic regression videos for binary classification for the error case where predicted value through logistic regression = 1 and actual value = 0 so error = 1. I didn't quite understand the statement " We'll have to penalize the learning algorithm by a very large cost". What does penalize a learning algorithm mean ?

Best Answer

Penalizing a Machine Leaning algorithm essentially means that you do not want your algorithm to be overfitted to your data. Have a look at this picture

enter image description here

The first plot shows an ML model that is under-fitted to the data and thus is not able to capture the pattern of the data.

The second plot shows that what your ML model will predict (dashed line) follows the trend of your data in some way.

The third picture on the right is very fitted to the data you train your algorithm on. This is bad for many reasons, but the main reason is that your training data does not contain all the data in the world.

The model in the second plot is better than the third because is more robust to predictions on new data (usually named test data).

Now, There exists a large number of algorithms that can fit the distribution of your data and you need to pick among these many.

A good way to do that is by "penalizing" the complexity of your model (e.g. assigning a negative cost (linear or quadratic cost are the most common) to the size of your weight parameter. This will result in a more robust model, i.e. similar to the one in the center.