![]() |
GURLS++
2.0.00
C++ Implementation of GURLS Matlab Toolbox
|
PerfRmse is the sub-class of Performance that evaluates prediction error.
#include <rmse.h>


Public Member Functions | |
| GurlsOptionsList * | execute (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. | |
| 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.
| X | not used |
| Y | labels matrix |
| opt | options with the following:
|
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;
}
| 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);
}