Here we are going to show performing nonlinear regression using the relevance vector machine implemented in the SparseBayes.jl package.

Setup

Let us load the necessary packages first.


In [ ]:
using SparseBayes
using Winston

Next, to ensure the repeatability of what is going to follow, we execute the following.


In [ ]:
srand(1000);

Synthetic Data Generation

Let us now generate some synthetic data for our regression. For our regression, the response variable will be the sinc function of the input with some additional noise.


In [ ]:
N = 100;
noiseStd = 0.1;
X = hcat(10 * (-1:2/(N-1):1));
Ytrue = sin(abs(X)) ./ abs(X);
Y = Ytrue + noiseStd * randn(N, 1);

Let us plot our synthetic data.


In [ ]:
plot(X, Y, "r*")
oplot(X, Ytrue, "g")

Fitting RVM Regression

Let us now create our RVM regression model. We are using the Gaussian kernel with sigma 0.3.


In [ ]:
sigma = 0.3;
kernelFun(X1, X2) = kernelGaussian(X1, X2, sigma);
mdl = RVMGaussianModel(kernelFun);

Next, we can fit the model to our data.


In [ ]:
@time fit!(mdl, X, Y[:,1]);