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

PredDual is the sub-class of Prediction that computes the predictions of a linear classifier in the dual formulation.

#include <dual.h>

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

List of all members.

Public Member Functions

OptMatrix< gMat2D< T > > * execute (const gMat2D< T > &X, const gMat2D< T > &Y, const GurlsOptionsList &opt)
 Computes the predictions of the linear classifier stored in opt.W and computed using the primal formulation, 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::PredDual< T >

Definition at line 67 of file dual.h.


Member Function Documentation

template<typename T >
OptMatrix< gMat2D< T > > * gurls::PredDual< 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)
  • C, X, W (settable with the class Optimizers and its subclasses RLSDual)
  • predkernel (required only if the subfield type of Kernel is different than "linear", and settable with the class PredKernel and its subclasses PredKernelTrainTest)
Returns:
pred matrix of predicted labels

Implements gurls::Prediction< T >.

Definition at line 85 of file dual.h.

{
    if(opt.hasOpt("kernel"))
    {
        if(opt.getOptValue<OptString>("kernel.type") == "linear")
        {
            PredPrimal<T> pred;
            return pred.execute(X, Y, opt);
        }
    }

    const gMat2D<T> &K = opt.getOptValue<OptMatrix<gMat2D<T> > >("predkernel.K");
    const gMat2D<T> &C = opt.getOptValue<OptMatrix<gMat2D<T> > >("optimizer.C");

    gMat2D<T>* Z = new gMat2D<T>(K.rows(), C.cols());


    dot(K.getData(), C.getData(), Z->getData(), K.rows(), K.cols(), C.rows(), C.cols(), Z->rows(), Z->cols(), CblasNoTrans, CblasNoTrans, CblasColMajor);

    return new OptMatrix<gMat2D<T> >(*Z);
}
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