![]() |
GURLS++
2.0.00
C++ Implementation of GURLS Matlab Toolbox
|
PerfPrecRec is the sub-class of Performance that evaluates prediction precision.
#include <precisionrecall.h>
Public Member Functions | |
GurlsOptionsList * | execute (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. |
Definition at line 60 of file precisionrecall.h.
GurlsOptionsList * gurls::PerfPrecRec< T >::execute | ( | const gMat2D< T > & | X, |
const gMat2D< T > & | Y, | ||
const GurlsOptionsList & | opt | ||
) | throw (gException) [virtual] |
X | input data matrix |
Y | labels matrix |
opt | options with the following:
|
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; }
static Performance<T>* gurls::Performance< T >::factory | ( | const std::string & | id | ) | throw (BadPerformanceCreation) [inline, static, inherited] |
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); }