Loss function
A number that measures how wrong a model's predictions are; training means making it small.
A loss function turns "how wrong is the model?" into a single number to minimise. The choice depends on the task:
- Mean squared error for regression.
- Cross-entropy (log-loss) for classification with probabilities.
- Hinge loss for support vector machines.
- Huber or absolute error when outliers should count less.
The loss you train on and the metric you report (accuracy, F1, RMSE) need not be the same: losses must be smooth enough to optimise, metrics must reflect what the business cares about.
See it in action
- Linear regressionFit the straight line (or hyperplane) that predicts a number with the least squared error.
- Logistic regressionThe workhorse classifier: a linear score turned into a calibrated probability by the sigmoid.
- Support vector machinesThe maximum-margin classifier: hinge loss, soft margins, the C parameter and support vectors.
- Evaluating models: metrics that matterConfusion matrices, precision and recall, F1, ROC and AUC, and regression errors.