Chapter 6. Conclusions
A.3 Matrix derivitives
B.1.2 AUCs obtained from run 1
The IBD analysis presented in the main body of the thesis uses only the second run of FAIMS measurements. Here we tabulate the results obtained using run 1.
Task AUC 95%CI
UC vs CD,V 0.94 0.88 – 0.99 CD vs UC,V 0.63 0.49 – 0.77 UC vs V 0.68 0.47 – 0.89 CD vs V 0.51 0.31 – 0.71 UC,CD vs V 0.59 0.41 – 0.77 UC vs CD 0.61 0.45 – 0.77
Appendix C
R Package Documentation
R packages have been developed as part of this thesis. All R packages are hosted un- der the Github account of the author https://github.com/JimSkinner. Packages may be downloaded and installed simply with the devtools package. For example, to install the gpclassifier package one may enter the following into an R terminal.
library(devtools)
install_github("JimSkinner/gpclassifier")
C.1
gpclassifier
The R package gpclassifier (https://github.com/JimSkinner/gpclassifier) implements a Gaussian process Classifier for binary classification tasks. The im- plementation uses the Expectation Propagation approxmation, and was developed following the book Gaussian Processes for Machine Learning by Rasmussen and Williams [2005].
The most common usage pattern of the package would be to use the GPC function to train a classifier model on a matrix of training data X.train and training labels Y.train, and then predict a new set of labels on a set of test data X.test.
library(gpclassifier)
model.gp = GPC(X.train, Y.train)
Package ‘gpclassifier’
June 27, 2017
Type Package
Title Implements a Gaussian Process binary Classifier Version 1.0
Date 2015-10-17 Author Jim Skinner
Maintainer Jim Skinner <[email protected]> Description
R implementation of a Gaussian Process Classifier using the Expectation Propagation approxi- mation detailed in (Gaussian Processes for Machine Learning; Rasmussen and Williams, 2006) License MIT
Depends methods
Imports optimx, memoise, kernlab, functional
Rtopics documented:
covarFun . . . 2 CovarFun-class . . . 2 covarFun.LatentPlusNoise . . . 3 covarFun.SE . . . 3 EP . . . 4 getCovarFun . . . 4 getDLml . . . 4 getHP . . . 4 getK . . . 5 getKernel . . . 5 getKernelGrad . . . 5 getLml . . . 6 GPC . . . 6 hpTune . . . 7 predict,GPC-method . . . 7 setHP<- . . . 8 update<- . . . 8 Index 92 CovarFun-class
covarFun Construtor method of CovarFun class
Description
Creates a new CovarFun object intended to be used inside a GPC Gaussian Process Classifier. Usage
covarFun(k, dk, hp) Arguments
k A kernel function (object, x, y) -> numeric() which, given data x and y returns
an inner product. Kernel hyperparameters may be accessed with object@hp.
dk A function (object, x, y) -> list() which returns the gradient of k with respect to
the hyprparameters in the form of a lsit of the same shape as the kyperparameters
hp A list of kernel hyperparameters.
Details
A CovarFun object extends the kernel object which supplies a kernel function along with a list of hyperparameters. CovarFun also supplies a function returning the gradient of the kernel with respect to the hyperparameters, such that the hyperparameters may be tuned by the GPC class. Examples
# Isotropic squared exponential covariance function with log length scale # (ll) hyperparameter
library("gpclassifier")
k = function(.Object, x, y) {
exp(-0.5 * sum(exp(-2*.Object@hp$ll) * (x-y)^2)) } hp = list(ll=0) dk = function(.Object, x, y) { list(ll=.Object@k(.Object, x, y) * exp(-2*.Object@hp$ll)*crossprod(x-y)) } C = covarFun(k, dk, hp)
CovarFun-class Class CovarFun.
Description
Class CovarFun defines a covariance function to be used as part of a GPC gaussian process classi- fier. A CovarFun object is made up of a kernel k(x,y), a set of hyperparameters used in the kernel, and a function returning the gradient of the kernel with respect to each of the hyperparameters.
covarFun.LatentPlusNoise 3
covarFun.LatentPlusNoise
Augment CovarFun with latent function and noise hyperparameters Description
Creates a covariance function k which augments some covariance function k_f with two extra hy- perparameters lsf and lsn such that: k(x, y) = exp(lsf)*k_f(x, y) + exp(lsn)*I[x=y] Automatically provides derivatives of lsf, lsn. Used for neater covariance funtion specifications. lsf, lsn stand for log(sigma^2_f) and log(sigma^2_n), where ’f’ labels the magnitude parameter and kernel for the latent function, whilst ’n’ labels the magnitude parameter for the noise.
Usage
covarFun.LatentPlusNoise(covarFun) Arguments
covarFun CovarFunobject to augment.
Value
covarFun augmented with lsf, lsn hyperparameterss for signal and noise magnitude. Examples
C = covarFun.LatentPlusNoise(covarFun.SE(0))
covarFun.SE Squared Exponential covariance function.
Description
Squared Exponential covariance function. Usage
covarFun.SE(ll = 0) Arguments
ll log length scale hyperparameter. ll must be of length 1 or the same length as
the input vectors. If length 1 then this is an isotropic SE covar fun, else there is a length scale for each dimension of the input.
Value
CovarFunfor a squared exponential covariance function
4 getHP
EP Calculate site parameters, likelihood and likelihood gradient using
Expectation Propagation
Description
Calculate site parameters, likelihood and likelihood gradient using Expectation Propagation Usage
EP(object)
getCovarFun GPC Return the covariance function (class CovarFun) used.
Description
GPC Return the covariance function (class CovarFun) used. Usage
getCovarFun(object)
getDLml Return partial derivatives of the log marginal likelihood with respect
to each of the hyperparameters.
Description
Return partial derivatives of the log marginal likelihood with respect to each of the hyperparameters. Usage
getDLml(object)
getHP Return the list of hyperparameters.
Description
Return the list of hyperparameters. Usage
getK 5
getK GPC Return the covariance matrix; the matrix of inner products be-
tween each pair of data points in the space induced by the covariance function.
Description
GPC Return the covariance matrix; the matrix of inner products between each pair of data points in the space induced by the covariance function.
Usage
getK(object)
getKernel Return kernel function k:x,y -> numeric(). Differs from the kernel
function specified when constructing the CovarFun, since the ker- nel function returned only requires parameters x,y, not object.
Description
Return kernel function k:x,y -> numeric(). Differs from the kernel function specified when con- structing the CovarFun, since the kernel function returned only requires parameters x,y, not ob- ject.
Usage
getKernel(object)
getKernelGrad Return kernel gradient function k:x,y -> list(). As with getKer-
nel(CovarFun), this differs from the kernel gradient function specified when constructing the CovarFun, since the function returned only requires parameters x,y, not object.
Description
Return kernel gradient function k:x,y -> list(). As with getKernel(CovarFun), this differs from the kernel gradient function specified when constructing the CovarFun, since the function returned only requires parameters x,y, not object.
Usage
6 GPC
getLml Return log marginal likelihood.
Description
Return log marginal likelihood. Usage
getLml(object)
GPC Class GPC.
Description
Class GPC defines a Gaussian Process Classifier. GPC(), GPC(X, Y, covarFun) creates a new GPC object used to predict labels for new input data.
Construct a new GPC object. Usage
GPC(X, Y, covarFun = NA) GPC(X, Y, covarFun = NA) Arguments
X Matrix of input data; sample in rows.
Y Logical vector of binary labels.
covarFun Covariance function to use. Must be of class CovarFun. If omitted, the squared
exponential covariance function is used by default. Details
Covariance function hyperparameters are selected automatically through maximum likelihood. This class is implemented using the Expectation Propagation approximation detailed in (Gaussian Pro- cesses for Machine Learning, Rasmussen and Williams, 2006).
Value
S4 object of class GPC, where covarance function hyperparameters have been set to their maximum likelihood estimates.
hpTune 7 Examples
# Create synthetic dataset X <- matrix(rnorm(60), ncol=2) Y <- rowSums(X^2) < 1
# New GPX Object with default squared exponential covariance function. gpc <- GPC(X, Y)
# Predict labels for new data Xst <- matrix(rnorm(60), ncol=2) Yst <- predict(gpc, Xst)
hpTune Return maximum likelihood covariance function hyperparameters
Description
Return maximum likelihood covariance function hyperparameters Usage
hpTune(object)
predict,GPC-method Predict labels from unlabelled data.
Description
Use a trained GPC classifier to produce label predictions of a new set of unlabelled data. Usage
## S4 method for signature 'GPC' predict(object, Xst)
Arguments
object A fitted GPC objet
Xst A matrix of data for which to produce label predictions
Examples
# Create synthetic dataset X <- matrix(rnorm(60), ncol=2) Y <- rowSums(X^2) < 1
# New GPX Object with default squared exponential covariance function. gpc <- GPC(X, Y)
# Predict labels for new data Xst <- matrix(rnorm(60), ncol=2)
8 update<-
setHP<- Change the CovarFun hyperparameter list to the list supplied.
Description
Change the CovarFun hyperparameter list to the list supplied. Usage
setHP(object) <- value
update<- Update X, Y or covarFun
Description
Update the data X, labels Y or covariance function covarFun, causing a recalculation of hyperpa- rameters, site parameters and covariance matrix.
Usage