A Cost Function (or loss function) is the metric used to measure how far off predictions are from the actual values. The goal of training is to minimize this function by adjusting the model’s parameters. Popular cost functions include mean squared error for regression and cross-entropy for classification.