Object to train Relevance Vector Machines for regression. More...
#include <mbl_rvm_regression_builder.h>
Public Member Functions | |
mbl_rvm_regression_builder () | |
Dflt ctor. | |
virtual | ~mbl_rvm_regression_builder () |
Destructor. | |
void | gauss_build (mbl_data_wrapper< vnl_vector< double > > &data, double var, const vnl_vector< double > &targets, vcl_vector< int > &index, vnl_vector< double > &weights, double &error_var) |
Train RVM given a set of vectors and set of target values. | |
void | build (const vnl_matrix< double > &kernel_matrix, const vnl_vector< double > &targets, vcl_vector< int > &index, vnl_vector< double > &weights, double &error_var) |
Train RVM given a distance matrix and set of target values. | |
Private Member Functions | |
void | design_matrix (const vnl_matrix< double > &kernel_matrix, const vcl_vector< int > &index, vnl_matrix< double > &F) |
Compute design matrix F from subset of elements in kernel matrix. | |
bool | update_step (const vnl_matrix< double > &design_matrix, const vnl_vector< double > &targets, const vcl_vector< int > &index0, const vcl_vector< double > &alpha0, double sqr_width0, vcl_vector< int > &index, vcl_vector< double > &alpha, double &error_var) |
Perform one iteration of optimisation. | |
Private Attributes | |
vnl_vector< double > | mean_wts_ |
Record of mean weights. | |
vnl_matrix< double > | S_ |
Record of covariance in weights. |
Object to train Relevance Vector Machines for regression.
Trains Relevance Vector Machines (see papers by Michael Tipping) for regression.
Definition at line 18 of file mbl_rvm_regression_builder.h.
mbl_rvm_regression_builder::mbl_rvm_regression_builder | ( | ) |
Dflt ctor.
Definition at line 25 of file mbl_rvm_regression_builder.cxx.
mbl_rvm_regression_builder::~mbl_rvm_regression_builder | ( | ) | [virtual] |
Destructor.
Definition at line 33 of file mbl_rvm_regression_builder.cxx.
void mbl_rvm_regression_builder::build | ( | const vnl_matrix< double > & | kernel_matrix, |
const vnl_vector< double > & | targets, | ||
vcl_vector< int > & | index, | ||
vnl_vector< double > & | weights, | ||
double & | error_var | ||
) |
Train RVM given a distance matrix and set of target values.
Resulting RVM has form f(x)=w[0]+sum w[i+1]K(x,vec[index[i]]) where K(x,y) is the kernel function, and index.size() gives the number of the selected vectors. Assuming the original data is vec[i], then on input we should have kernel_matrix(i,j)=K(vec[i],vec[j]) Note that on exit, weights.size()==index.size()+1 weights[0] is the constant offset, and weights[i+1] corresponds to selected input vector index[i].
The algorithm involves inverting an (n+1)x(n+1) matrix, where n is the number of vectors to consider as relevant vectors. This doesn't have to be all the samples. For efficiency, one can provide the kernel matrix as an m x n matrix, where m is the number of samples to test against (targets.size()==m) but n<=m samples are to be considered as potential relevant vectors (ie the first n).
kernel_matrix | (i,j) element gives kernel function between i and j training vectors |
targets[i] | gives value at vector i |
index | returns indices of selected vectors |
weights | returns weights for selected vectors |
error_var | returns estimated error variance for resulting function |
kernel_matrix | (i,j) element gives kernel function between i and j training vectors |
targets[i] | gives value at vector i |
index | returns indices of selected vectors |
weights | returns weights for selected vectors |
error_var | returns variance term for gaussian kernel |
Definition at line 173 of file mbl_rvm_regression_builder.cxx.
void mbl_rvm_regression_builder::design_matrix | ( | const vnl_matrix< double > & | kernel_matrix, |
const vcl_vector< int > & | index, | ||
vnl_matrix< double > & | F | ||
) | [private] |
Compute design matrix F from subset of elements in kernel matrix.
Uses gaussian distance expression with variance var
Definition at line 38 of file mbl_rvm_regression_builder.cxx.
void mbl_rvm_regression_builder::gauss_build | ( | mbl_data_wrapper< vnl_vector< double > > & | data, |
double | var, | ||
const vnl_vector< double > & | targets, | ||
vcl_vector< int > & | index, | ||
vnl_vector< double > & | weights, | ||
double & | error_var | ||
) |
Train RVM given a set of vectors and set of target values.
Resulting RVM has form f(x)=w[0]+sum w[i+1]K(x,data[index[i]]) where K(x,y)=exp(-|x-y|^2/2var), and index.size() gives the number of the selected vectors. Note that on exit, weights.size()==index.size()+1 weights[0] is the constant offset, and weights[i+1] corresponds to selected input vector index[i].
data[i] | training vectors |
targets[i] | gives value at vector i |
index | returns indices of selected vectors |
weights | returns weights for selected vectors |
error_var | returns estimated error variance for resulting function |
Uses gaussian kernel function with variance var
data[i] | training vectors |
targets[i] | gives value at vector i |
index | returns indices of selected vectors |
weights | returns weights for selected vectors |
error_var | returns variance term for gaussian kernel |
Definition at line 62 of file mbl_rvm_regression_builder.cxx.
bool mbl_rvm_regression_builder::update_step | ( | const vnl_matrix< double > & | design_matrix, |
const vnl_vector< double > & | targets, | ||
const vcl_vector< int > & | index0, | ||
const vcl_vector< double > & | alpha0, | ||
double | sqr_width0, | ||
vcl_vector< int > & | index, | ||
vcl_vector< double > & | alpha, | ||
double & | error_var | ||
) | [private] |
Perform one iteration of optimisation.
Definition at line 91 of file mbl_rvm_regression_builder.cxx.
vnl_vector<double> mbl_rvm_regression_builder::mean_wts_ [private] |
Record of mean weights.
Definition at line 22 of file mbl_rvm_regression_builder.h.
vnl_matrix<double> mbl_rvm_regression_builder::S_ [private] |
Record of covariance in weights.
Definition at line 25 of file mbl_rvm_regression_builder.h.