GURLS++  2.0.00
C++ Implementation of GURLS Matlab Toolbox
gurls::PredGPRegr< T > Class Template Reference

PredGPRegr is the sub-class of Prediction that computes the predictions of GP.

#include <predgp.h>

Inheritance diagram for gurls::PredGPRegr< T >:
Collaboration diagram for gurls::PredGPRegr< T >:

List of all members.

Public Member Functions

GurlsOptionsListexecute (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.

Detailed Description

template<typename T>
class gurls::PredGPRegr< T >

Definition at line 62 of file predgp.h.


Member Function Documentation

template<typename T >
GurlsOptionsList * gurls::PredGPRegr< T >::execute ( const gMat2D< T > &  X,
const gMat2D< T > &  Y,
const GurlsOptionsList opt 
) [virtual]
Parameters:
Xinput data matrix
Ylabels matrix
optoptions with the following:
  • Kernel (default)
  • L, alpha (settable with the class Optimizers and its subclasses RLSGP)
  • predkernel (settable with the class PredKernel and its subclasses PredKernelTrainTest, must contain the fields K and Ktest)
Returns:
pred GurlsOptionList with the following fields:
  • means = matrix of output means
  • covs = matrix of output covariances

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;
}
template<typename T>
static Prediction<T>* gurls::Prediction< T >::factory ( const std::string &  id) throw (BadPredictionCreation) [inline, static, inherited]
Warning:
The returned pointer is a plain, un-managed pointer. The calling function is responsible of deallocating the object.

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);
    }

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends