What is a Cost function?

A function we minimize to make our prediction close to the target values. in linear regression, we want to find an equation of line which is a close approximation of our training dataset, we we use sum of squared errors as the cost function and attempt to minimize that.