A constant mean function assigns the same expected value to every input in a Gaussian process. It provides a simple prior prediction before observations are incorporated, while the covariance function models relationships between inputs. section 3.2
Use a nonzero constant when prior knowledge suggests that objective values occupy a particular range. Accuracy commonly lies between 0 and 1, while housing prices are positive, so a positive constant can be more appropriate than a zero mean. section 3.3.2 section 3.2
Choose and train the constant mean as follows:
- Treat the constant as a candidate expected objective value, such as 0 or 2. section 3.3.2
- Compare candidates using the exact marginal log likelihood, which measures how well the GP explains its training data. section 3.3.2
- Optimize the mean constant with gradient descent, minimizing negative marginal log likelihood alongside other GP hyperparameters when appropriate. section 3.3.2 section 12.1.2
- Switch both the model and likelihood from training mode to evaluation mode before making predictions. section 12.1.2
Comparing zero and positive means
Two otherwise comparable GP models use constant means of 0 and 2. The model with mean 2 has higher log likelihood, and its predictions revert toward 2 away from observed data, indicating a better fit for the training observations. section 3.3.2
Figure 3.6 GP predictions, given two different constant mean functions. The value 2 gives a higher likelihood value than the value 0, indicating the former mean function is a better fit than the latter.
Compare GP predictions produced by two constant mean values and inspect how the better likelihood changes prior reversion. section 3.3.2
In GPyTorch, implement the mean with gpytorch.means.ConstantMean. A regular GP can combine it with an RBF or Matérn kernel and a ScaleKernel, then learn the constant through Adam and the marginal-log-likelihood objective. section 12.1.2 section 7.5
