![]() |
GURLS++
2.0.00
C++ Implementation of GURLS Matlab Toolbox
|
PredGPRegr is the sub-class of Prediction that computes the predictions of GP.
#include <predgp.h>


Public Member Functions | |
| GurlsOptionsList * | execute (const gMat2D< T > &X, const gMat2D< T > &Y, const GurlsOptionsList &opt) |
| computes the predictive distribution of the GP stored in opt.optimizer (L and alpha), on the samples passed in the X matrix. | |
Static Public Member Functions | |
| static Prediction< T > * | factory (const std::string &id) throw (BadPredictionCreation) |
| Factory function returning a pointer to the newly created object. | |
| GurlsOptionsList * gurls::PredGPRegr< T >::execute | ( | const gMat2D< T > & | X, |
| const gMat2D< T > & | Y, | ||
| const GurlsOptionsList & | opt | ||
| ) | [virtual] |
| X | input data matrix |
| Y | labels matrix |
| opt | options with the following:
|
Implements gurls::Prediction< T >.
Definition at line 82 of file predgp.h.
{
// pred.means = opt.predkernel.K*opt.rls.alpha;
const GurlsOptionsList* predkernel = opt.getOptAs<GurlsOptionsList>("predkernel");
const gMat2D<T> &K = predkernel->getOptValue<OptMatrix<gMat2D<T> > >("K");
const unsigned long kr = K.rows();
const unsigned long kc = K.cols();
const GurlsOptionsList* rls = opt.getOptAs<GurlsOptionsList>("optimizer");
const gMat2D<T> &L = rls->getOptValue<OptMatrix<gMat2D<T> > >("L");
const unsigned long lr = L.rows();
const unsigned long lc = L.cols();
const gMat2D<T> &alpha = rls->getOptValue<OptMatrix<gMat2D<T> > >("alpha");
gMat2D<T>* means_mat = new gMat2D<T>(kr, alpha.cols());
dot(K.getData(), alpha.getData(), means_mat->getData(), kr, kc, alpha.rows(), alpha.cols(), kr, alpha.cols(), CblasNoTrans, CblasNoTrans, CblasColMajor);
const unsigned long n = X.rows();
// pred.vars = zeros(n,1);
gMat2D<T> *vars_mat = new gMat2D<T>(n, 1);
T* vars = vars_mat->getData();
T* v = new T[std::max(kc, n)];
for(unsigned long i = 0; i<n; ++i)
{
getRow(K.getData(), kr, kc, i, v);
mldivide_squared(L.getData(), v, lr, lc, kc, 1, CblasTrans);
vars[i] = dot(kc, v, 1, v, 1);
}
// pred.vars = opt.predkernel.Ktest - pred.vars;
const gMat2D<T> &Ktest = predkernel->getOptValue<OptMatrix<gMat2D<T> > >("Ktest");
copy(v, Ktest.getData(), n);
axpy(n, (T)-1.0, vars, 1, v, 1);
copy(vars, v, n);
delete[] v;
GurlsOptionsList* pred = new GurlsOptionsList("pred");
pred->addOpt("means", new OptMatrix<gMat2D<T> >(*means_mat));
pred->addOpt("vars", new OptMatrix<gMat2D<T> >(*vars_mat));
return pred;
}
| static Prediction<T>* gurls::Prediction< T >::factory | ( | const std::string & | id | ) | throw (BadPredictionCreation) [inline, static, inherited] |
Definition at line 112 of file pred.h.
{
if(id == "primal")
return new PredPrimal<T>;
if(id == "dual")
return new PredDual<T>;
if(id == "gpregr")
return new PredGPRegr<T>;
if(id == "randfeats")
return new PredRandFeats<T>;
throw BadPredictionCreation(id);
}