GPF is a small Fortran library for Gaussian process regression. It currently implements value predictions with dense Gaussian processes, and projected-process approximate Gaussian processes (described by Rasmussen and Williams, 2006, chapter 8).
GPF has the following external dependencies
- LAPACK
- NLopt (http://ab-initio.mit.edu/wiki/index.php/NLopt)
- makedepf90
GPF is written in standard Fortran 2008. A makefile is provided for gfortran on linux. It has been tested with gfortran 6.2, although earlier versions may also work.
Issuing
$ make all
will build the library (lib/libgpf.a) and tests. The tests can be run with
$ make test
Some example programs using the library can be found in the directory programs
. See these
directories for further details.
- gp_train: train (and optionally optimize) a sparse GP from data files
- gp_predict: read in a GP file and produce outputs for points read from standard input
Ensure that the module files gp.mod
, gp_dense.mod
and gp_sparse.mod
are in the
include path of your compiler. Link with the static library libgpf.a
by providing
the -lgpf
flag (gfortran).
Include the module with either use m_gp_dense
or use m_gp_sparse
. These modules provide
the types DenseGP
(full Gaussian process) and SparseGP
(Gaussian process from the
projected process approximation). Both are subtypes of the class BaseGP
.
A DenseGP
object can be constructed as follows:
type(DenseGP) my_gp
type(cov_sqexp) cf
type(noise_value_only) nm
my_gp = DenseGP(nu=[1.d-9], theta=[1.4_dp], x=x(1:N,:), obs_type=obs_type(1:N),
t=t(1:N), CovFunction=cf, NoiseModel=nm)
where nu
, theta
, x
and t
are double precision arrays, and obs_type
is an integer
array; x
has rank two, the first dimension , and the second dimension defining the dimension of
the process.
nu
: the noise hyperparameterstheta
: the covariance hyperparametersx
: the coordinates of the input dataobs_type
: the types of the observations. Ifobs_type(j)
is 0, thent(j)
represents an observation of the value of the underlying function. Ifobs_type(j)
is i with i > 0, thent(j)
represents an observation of the partial derivative of the underlying function with respect to the i th component of x.CovFunction
: the covariance function to use (of classcov_fn
, see below)NoiseModel
: the noise model to use (of classnoise_model
, see below)
A SparseGP
object can be constructed similarly:
type(SparseGP) my_gp
my_gp = SparseGP(nsparse, nu, theta, x, obs_type, t, cf, nm)
nsparse
: an integer representing the number of privileged points to use in the projected process. This should be strictly less than the number of elements in the training data set.- The remaining parameters are the same as
DenseGP
.
DenseGP('in.gp')
or
SparseGP('in.gp')
class(BaseGP) my_gp
my_gp%write_out('out.gp')
use gp_optim
class(BaseGP) my_gp
...
log_lik_optim(my_gp, lbounds, ubounds, optimize_max_iter, optimize_ftol)
my_gp
: an object of class BaseGP (either SparseGP or DenseGP)lbounds
andubounds
: double precision arrays of length equal to the number of noise hyperparemeters plus the number of covariance hyperparameters, representing lower and upper bounds of the hyperparameters in the optimization.optimize_max_iter
: the maximum number of iterations to perform in the optimization before stopping.optimize_ftol
: a double precision value stop the optimization when an optimization step changes the log likelihood by less than this amount.
A prediction of the underlying function at a coordinate x
can be obtained as
y = my_gp%predict(x, obs_type)
x
: a double precision array with length of the dimension of the processobs_type
: an integer representing the type of the observation. A value of0
gives a prediction of the value. A value i with i > 1, gives the predicted partial derivative of y with respect to the i th component of x.
Covariance functions extend the abstract type cov_fn
(see [src/cov.f90]).
A square-exponential covariance function is defined as cov_sqexp
([src/cov_sqexp.f90]), and
others can be defined similarly.
Noise models extend the abstract type noise_model
.
A noise model contains a function noise
, taking the type of observation, the noise hyperparameters,
and returning the variance of the noise.
C. Rasmussen and C. Williams. Gaussian Processes for Machine Learning. Adaptative Computation and Machine Learning Series. MIT Press, 2006. ISBN 9780262182539.