liveBook · Manning

Negative log-likelihood

As explained in Machine Learning Algorithms in Depth

A negative log likelihood is a loss equal to the negative logarithm of the likelihood assigned to observed outcomes by a probabilistic model.

Negative log-likelihood (NLL) measures how poorly a probabilistic model assigns probability to observed outcomes: it is the negative logarithm of their likelihood. Maximizing log likelihood is therefore equivalent to minimizing NLL. section 5.4 section 11.2.1

For binary logistic regression, NLL is the loss optimized from conditional class probabilities. Stochastic gradient descent updates parameters using its gradient; regularization can be added to control parameter size. section 5.4

The same objective extends from classification to learned probability densities:

  • A mixture density network predicts Gaussian-mixture parameters, including means, covariances, and mixture proportions, and minimizes the resulting NLL. section 11.2.1
  • The neural network enforces positive variances with exponential activations and mixture weights summing to one with softmax activations. section 11.2.1
  • Under an isotropic Gaussian covariance assumption, the multivariate density can be rewritten as a product across dimensions before constructing the loss. section 11.2.1

Two implementations

A from-scratch SGD logistic-regression implementation computes a regularized objective and gradient, schedules the learning rate, and exposes fit and predict operations. A Keras/TensorFlow Gaussian mixture density network generates synthetic multivariate data, predicts constrained mixture parameters, computes NLL, and reports training and validation loss. section 5.4 section 11.2.1

Figure 11.7 A multioutput neural network used to learn Gaussian parameters
figure

Shows the multi-output neural-network structure used to learn Gaussian mixture parameters for NLL training. section 11.2.1

How Machine Learning Algorithms in Depth covers it

How deep it goes
Derives gradients and implements SGD for logistic regression, then constructs constrained Gaussian-mixture loss, stopping short of broader likelihood theory.
Examples
Uses binary logistic regression with synthetic two-class data and a Gaussian mixture density network trained on synthetic multivariate data.
What it assumes
Assumes conditional probability models and parameterized distributions while deriving the logistic-regression gradient and Gaussian-mixture formulation.
What you can do after
Builds NLL objectives from scratch, optimizes logistic regression with SGD, and applies NLL in a Keras/TensorFlow mixture density network.
How it connects
Connects negative log-likelihood to logistic regression, softmax, stochastic gradient descent, regularization, mixture density networks, and Gaussian mixture models.

Also explained in

Compare how 7 books explain negative log-likelihood →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Algorithms in Depth. The section links point to the parts of the book it draws on.