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

RLSRandFeats is the sub-class of Optimizer that computes a classifier for the primal formulation of RLS using the Random Features approach proposed in: Ali Rahimi, Ben Recht; Random Features for Large-Scale Kernel Machines; in Neural Information Processing Systems (NIPS) 2007. More...

#include <rlsrandfeats.h>

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

List of all members.

Public Member Functions

GurlsOptionsListexecute (const gMat2D< T > &X, const gMat2D< T > &Y, const GurlsOptionsList &opt)
 Computes a classifier for the primal formulation of RLS using the Random Features approach.

Static Public Member Functions

static Optimizer< T > * factory (const std::string &id) throw (BadOptimizerCreation)
 Factory function returning a pointer to the newly created object.

Detailed Description

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

The regularization parameter is set to the one found in opt.paramsel. In case of multiclass problems, the regularizers need to be combined with the opt.singlelambda function.

Definition at line 70 of file rlsrandfeats.h.


Member Function Documentation

template<typename T >
GurlsOptionsList * gurls::RLSRandFeats< T >::execute ( const gMat2D< T > &  X,
const gMat2D< T > &  Y,
const GurlsOptionsList opt 
) [virtual]
Parameters:
Xinput data matrix
Ylabels matrix
structof options with the following fields:
  • paramsel.lambdas (set by the paramsel tasks)
  • singlelambda
  • randfeats.D
  • randfeats.samplesize
Returns:
adds to opt the field optimizer, which is a list containing the following fields: -W: matrix of coefficient vectors of rls estimator for each class -C: empty matrix -X: empty matrix

Implements gurls::Optimizer< T >.

Definition at line 94 of file rlsrandfeats.h.

{
    //    lambda = opt.singlelambda(opt.paramsel.lambdas);
    const gMat2D<T> &ll = opt.getOptValue<OptMatrix<gMat2D<T> > >("paramsel.lambdas");
    T lambda = opt.getOptAs<OptFunction>("singlelambda")->getValue(ll.getData(), ll.getSize());

    const unsigned long sampleSize = opt.getOptAsNumber("randfeats.samplesize");
    const unsigned long D = opt.getOptAsNumber("randfeats.D");

//    n = size(X,1);
    const unsigned long n = X.rows();
//    const unsigned long d = X.cols();
    const unsigned long t = Y.cols();

//    if or(opt.randfeats.samplesize < 0, opt.randfeats.samplesize > n)
//        ni = n;
//    else
//        ni = opt.randfeats.samplesize;
//    end

    const unsigned long ni = (sampleSize < 0 || sampleSize > n)? n : sampleSize;

    const unsigned long D2 = 2*D;

    T *XtX = new T[D2*D2];
    T *Xty = new T[D2*t];

//    [XtX,Xty,rls.proj] = rp_factorize_large_real(X,y,opt.randfeats.D,ni);
    gMat2D<T> *rls_proj = rp_factorize_large_real(X, Y, D, ni, XtX, Xty);

//    rls.W = rls_primal_driver( XtX, Xty, n, lambda );
    gMat2D<T> *W = rls_primal_driver(XtX, Xty, D2, D2, t, lambda);

    delete [] XtX;
    delete [] Xty;

    GurlsOptionsList *optimizer = new GurlsOptionsList("optimizer");


    optimizer->addOpt("proj", new OptMatrix<gMat2D<T> >(*rls_proj));

//    rls.W = rls_primal_driver( XtX, Xty, n, lambda );
    optimizer->addOpt("W", new OptMatrix<gMat2D<T> >(*W));

//    rls.C = [];
    gMat2D<T>* emptyC = new gMat2D<T>();
    optimizer->addOpt("C", new OptMatrix<gMat2D<T> >(*emptyC));

//    rls.X = [];
    gMat2D<T>* emptyX = new gMat2D<T>();
    optimizer->addOpt("X", new OptMatrix<gMat2D<T> >(*emptyX));


    return optimizer;
}
template<typename T>
static Optimizer<T>* gurls::Optimizer< T >::factory ( const std::string &  id) throw (BadOptimizerCreation) [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 130 of file optimization.h.

    {
      if(id == "rlsauto")
        return new RLSAuto<T>;
      if(id == "rlsprimal")
        return new RLSPrimal<T>;
      if(id == "rlsprimalr")
        return new RLSPrimalr<T>;
      if(id == "rlsdual")
        return new RLSDual<T>;
      if(id == "rlsdualr")
        return new RLSDualr<T>;
      if(id == "rlspegasos")
        return new RLSPegasos<T>;
      if(id == "rlsgpregr")
        return new RLSGPRegr<T>;
      if(id == "rlsprimalrecinit")
        return new RLSPrimalRecInit<T>;
      if(id == "rlsprimalrecupdate")
        return new RLSPrimalRecUpdate<T>;
      if(id == "rlsrandfeats")
        return new RLSRandFeats<T>;

        throw BadOptimizerCreation(id);
    }

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