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

PerfRmse is the sub-class of Performance that evaluates prediction error.

#include <rmse.h>

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

List of all members.

Public Member Functions

GurlsOptionsListexecute (const gMat2D< T > &X, const gMat2D< T > &Y, const GurlsOptionsList &opt) throw (gException)
 Evaluates the root mean square error of the predicted labels stored in the field pred of opt with respect to the true input labels Y.

Static Public Member Functions

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

Detailed Description

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

Definition at line 62 of file rmse.h.


Member Function Documentation

template<typename T >
GurlsOptionsList * gurls::PerfRmse< T >::execute ( const gMat2D< T > &  X,
const gMat2D< T > &  Y,
const GurlsOptionsList opt 
) throw (gException) [virtual]

It computes it as the frobenius norm over the classes and the samples of the difference between the true and predicted labels matrices.

Parameters:
Xnot used
Ylabels matrix
optoptions with the following:
  • pred (settable with the class Prediction and its subclasses)
Returns:
perf, a GurslOptionList equal to the field pred of opt, with the following fields added or substituted:
  • rmse = root mean square error for each class/task
  • forho = -rmse

Implements gurls::Performance< T >.

Definition at line 80 of file rmse.h.

{
    const unsigned long rows = Y.rows();
    const unsigned long cols = Y.cols();

    const T* y_true = Y.getData();

//    if isfield (opt,'perf')
//        p = opt.perf; % lets not overwrite existing performance measures.
//                  % unless they have the same name
//    end

    GurlsOptionsList* perf;

    if(opt.hasOpt("perf"))
    {
        GurlsOptionsList* tmp_opt = new GurlsOptionsList("tmp");
        tmp_opt->copyOpt("perf", opt);

        perf = GurlsOptionsList::dynacast(tmp_opt->getOpt("perf"));
        tmp_opt->removeOpt("perf", false);
        delete tmp_opt;

        perf->removeOpt("rmse");
        perf->removeOpt("forho");
//        perf->removeOpt("forplot");
    }
    else
        perf = new GurlsOptionsList("perf");


    const gMat2D<T> &pred = opt.getOptValue<OptMatrix<gMat2D<T> > >("pred");

    T *pred_t = new T[pred.getSize()];
    copy(pred_t, pred.getData(), pred.getSize());

    //pred = rows*cols

//     n    = size(X,1);
    const T n = static_cast<T>(rows);

//     diff     = opt.pred - y;
    axpy(rows*cols, (T)-1.0, y_true, 1, pred_t, 1);

//  p.rmse = norm(diff,'fro') / sqrt(n);
    T rmse = nrm2<T>(rows*cols, pred_t, 1)/sqrt(n);

    delete [] pred_t;

    perf->addOpt("rmse", new OptNumber(rmse));

//    p.forho   = -p.rmse;
    perf->addOpt("forho", new OptNumber(-rmse));

//    p.forplot     = p.rmse;
//    perf->addOpt("forplot", new OptNumber(rmse));

    return perf;
}
template<typename T>
static Performance<T>* gurls::Performance< T >::factory ( const std::string &  id) throw (BadPerformanceCreation) [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 111 of file perf.h.

    {
        if(id == "precrec")
            return new PerfPrecRec<T>;
        if(id == "macroavg")
            return new PerfMacroAvg<T>;
        if(id == "rmse")
            return new PerfRmse<T>;

        throw BadPerformanceCreation(id);
    }

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