![]() |
GURLS++
2.0.00
C++ Implementation of GURLS Matlab Toolbox
|
GurlsWrapper is the base class for all gurls++ wrappers.
#include <wrapper.h>


Public Types | |
| enum | ProblemType { CLASSIFICATION, REGRESSION } |
Public Member Functions | |
| virtual T | eval (const gVec< T > &X, unsigned long *index=NULL) |
| Estimates label for a new input point. | |
| virtual gMat2D< T > * | eval (const gMat2D< T > &X)=0 |
| Estimates label for an input matrix. | |
| virtual const GurlsOptionsList & | getOpt () const |
| Returns a const reference to the options structure. | |
| GurlsWrapper (const std::string &name) | |
| Constructor. | |
| virtual void | loadModel (const std::string &fileName) |
| Loads a computed model from a file. | |
| virtual void | saveModel (const std::string &fileName) |
| Saves the computed model to file. | |
| virtual void | setNparams (unsigned long value) |
| virtual void | setParam (double value) |
| virtual void | setProblemType (ProblemType value) |
| virtual void | setSplitProportion (double value) |
| virtual void | train (const gMat2D< T > &X, const gMat2D< T > &y)=0 |
| Initial parameter selection and training. | |
| ~GurlsWrapper () | |
| Destructor. | |
Protected Member Functions | |
| virtual bool | trainedModel () |
| Checks if model has already been trained. | |
Protected Attributes | |
| std::string | name |
| Name of the options structure. | |
| GurlsOptionsList * | opt |
| Options structure where information about initial training is stored. | |
| ProblemType | probType |
| Problem type. | |
| gurls::GurlsWrapper< T >::GurlsWrapper | ( | const std::string & | name | ) |
| name | Name of the options structure that will be initialized |
Definition at line 10 of file wrapper.hpp.
:opt(NULL), name(name) { opt = new GurlsOptionsList(name, true); setSplitProportion(0.2); setNparams(20); setProblemType(CLASSIFICATION); }
| T gurls::GurlsWrapper< T >::eval | ( | const gVec< T > & | X, |
| unsigned long * | index = NULL |
||
| ) | [virtual] |
| [in] | X | Input point |
| [out] | index | Index of the estimated label |
Definition at line 26 of file wrapper.hpp.
{
if(!trainedModel())
throw gException("Error, Train Model First");
gMat2D<T>X_mat(1, X.getSize());
copy(X_mat.getData(), X.getData(), X.getSize());
gMat2D<T>* pred_mat = eval(X_mat);
const T* pred = pred_mat->getData();
const unsigned long size = pred_mat->getSize();
const T* max = std::max_element(pred, pred+size);
T ret = *max;
if(index != NULL)
*index = max-pred;
delete pred_mat;
return ret;
}
| virtual gMat2D<T>* gurls::GurlsWrapper< T >::eval | ( | const gMat2D< T > & | X | ) | [pure virtual] |
| [in] | X | Input matrix |
Implemented in gurls::RecursiveRLSWrapper< T >, gurls::NystromWrapper< T >, gurls::RandomFeaturesWrapper< T >, gurls::ICholWrapper< T >, gurls::RLSWrapper< T >, gurls::KernelRLSWrapper< T >, and gurls::GPRWrapper< T >.
| void gurls::GurlsWrapper< T >::loadModel | ( | const std::string & | fileName | ) | [virtual] |
| fileName | name of the file containing the data to load |
Definition at line 61 of file wrapper.hpp.
| void gurls::GurlsWrapper< T >::saveModel | ( | const std::string & | fileName | ) | [virtual] |
| fileName | name of the file where data will be saved |
Definition at line 55 of file wrapper.hpp.
| void gurls::GurlsWrapper< T >::setNparams | ( | unsigned long | value | ) | [virtual] |
| [in] | value |
Definition at line 67 of file wrapper.hpp.
| void gurls::GurlsWrapper< T >::setParam | ( | double | value | ) | [virtual] |
| [in] | value |
Reimplemented in gurls::NystromWrapper< T >.
Definition at line 79 of file wrapper.hpp.
{
if(!opt->hasOpt("paramsel"))
opt->addOpt("paramsel", new GurlsOptionsList("paramsel"));
if(opt->hasOpt("paramsel.lambdas"))
opt->getOptValue<OptMatrix<gMat2D<T> > >("paramsel.lambdas").getData()[0] = (T)value;
else
{
gMat2D<T> * lambdas = new gMat2D<T>(1,1);
lambdas->getData()[0] = (T)value;
opt->getOptAs<GurlsOptionsList>("paramsel")->addOpt("lambdas", new OptMatrix<gMat2D<T> >(*lambdas));
}
setNparams(1);
}
| void gurls::GurlsWrapper< T >::setProblemType | ( | typename GurlsWrapper< T >::ProblemType | value | ) | [virtual] |
| [in] | value |
Definition at line 103 of file wrapper.hpp.
{
probType = value;
opt->getOptValue<OptString>("hoperf") = (value == CLASSIFICATION)? "macroavg": "rmse";
}
| void gurls::GurlsWrapper< T >::setSplitProportion | ( | double | value | ) | [virtual] |
| [in] | value |
Definition at line 97 of file wrapper.hpp.
{
opt->getOptValue<OptNumber>("hoproportion") = value;
}
| virtual void gurls::GurlsWrapper< T >::train | ( | const gMat2D< T > & | X, |
| const gMat2D< T > & | y | ||
| ) | [pure virtual] |
| [in] | X | Input data matrix |
| [in] | Y | Labels matrix |
Implemented in gurls::KernelWrapper< T >, gurls::RandomFeaturesWrapper< T >, gurls::RecursiveRLSWrapper< T >, gurls::NystromWrapper< T >, gurls::RLSWrapper< T >, gurls::KernelRLSWrapper< T >, gurls::ICholWrapper< T >, and gurls::GPRWrapper< T >.
| bool gurls::GurlsWrapper< T >::trainedModel | ( | ) | [protected, virtual] |
| value | |
| value |
Definition at line 111 of file wrapper.hpp.