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

PerfPrecRec is the sub-class of Performance that evaluates prediction precision.

#include <precisionrecall.h>

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

List of all members.

Public Member Functions

GurlsOptionsListexecute (const gMat2D< T > &X, const gMat2D< T > &Y, const GurlsOptionsList &opt) throw (gException)
 Evaluates the average precision per class through precision and recall.

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::PerfPrecRec< T >

Definition at line 60 of file precisionrecall.h.


Member Function Documentation

template<typename T >
GurlsOptionsList * gurls::PerfPrecRec< T >::execute ( const gMat2D< T > &  X,
const gMat2D< T > &  Y,
const GurlsOptionsList opt 
) throw (gException) [virtual]
Parameters:
Xinput data matrix
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:
  • ap = array of average precision for each class
  • forho = ap

Implements gurls::Performance< T >.

Definition at line 79 of file precisionrecall.h.

{
    const int rows = Y.rows();
    const int cols = Y.cols();

    //    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("ap");
        perf->removeOpt("forho");
//        perf->removeOpt("forplot");
    }
    else
        perf = new GurlsOptionsList("perf");

//    y_true = y;
    const T* y_true = Y.getData();

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

    gMat2D<T>* ap_mat = new gMat2D<T>(1, cols);
    T* ap = ap_mat->getData();

    T* work = new T[4*rows];

//    T = size(y,2);
//    for t = 1:T,
    for(int i=0; i<cols; ++i)
    {
//        p.ap(t) = precrec_driver(y_pred(:,t), y_true(:,t),0);
//        p.forho(t) = p.ap(t);

        ap[i] = precrec_driver(y_pred.getData()+(i*rows), y_true+(i*rows), rows, work);

//        p.forplot(t) = p.ap(t);
    }

    delete [] work;

    OptMatrix<gMat2D<T> >* ap_opt = new OptMatrix<gMat2D<T> >(*ap_mat);
    perf->addOpt("ap", ap_opt);

    OptMatrix<gMat2D<T> >* forho_opt = new OptMatrix<gMat2D<T> >(*(new gMat2D<T>(*ap_mat)));
    perf->addOpt("forho", forho_opt);

//    OptMatrix<gMat2D<T> >* forplot_opt = new OptMatrix<gMat2D<T> >(*(new gMat2D<T>(*ap_mat)));
//    perf->addOpt("forplot", forplot_opt);

    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