KernelWrapper is the base class for all gurls++ wrappers.
#include <wrapper.h>
List of all members.
Public Types |
enum | KernelType { RBF,
LINEAR
} |
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.
|
| KernelWrapper (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 | setKernelType (KernelType value) |
virtual void | setNparams (unsigned long value) |
virtual void | setNSigma (unsigned long value) |
virtual void | setParam (double value) |
virtual void | setProblemType (ProblemType value) |
virtual void | setSigma (double value) |
virtual void | setSplitProportion (double value) |
virtual void | train (const gMat2D< T > &X, const gMat2D< T > &y)=0 |
| Initial parameter selection and training.
|
Protected Member Functions |
virtual bool | trainedModel () |
| Checks if model has already been trained.
|
Protected Attributes |
KernelType | kType |
| Kernel type used in train and eval.
|
std::string | name |
| Name of the options structure.
|
GurlsOptionsList * | opt |
| Options structure where information about initial training is stored.
|
ProblemType | probType |
| Problem type.
|
Detailed Description
template<typename T>
class gurls::KernelWrapper< T >
Definition at line 177 of file wrapper.h.
Constructor & Destructor Documentation
- Parameters:
-
name | Name of the options structure that will be initialized |
Definition at line 118 of file wrapper.hpp.
: GurlsWrapper<T>(name), kType(RBF)
{
GurlsOptionsList *paramsel = new GurlsOptionsList("paramsel");
this->opt->addOpt("paramsel", paramsel);
}
Member Function Documentation
- Parameters:
-
[in] | X | Input point |
[out] | index | Index of the estimated label |
- Returns:
- 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;
}
- Parameters:
-
fileName | name of the file containing the data to load |
Definition at line 61 of file wrapper.hpp.
- Parameters:
-
fileName | name of the file where data will be saved |
Definition at line 55 of file wrapper.hpp.
- Parameters:
-
Definition at line 67 of file wrapper.hpp.
{
opt->getOptValue<OptNumber>("nlambda") = value;
if(opt->hasOpt("paramsel.lambdas") && value > 1.0)
{
std::cout << "Warning: ignoring previous values of the regularization parameter" << std::endl;
opt->getOptAs<GurlsOptionsList>("paramsel")->removeOpt("lambdas");
}
}
- Parameters:
-
Definition at line 161 of file wrapper.hpp.
{
this->opt->template getOptValue<OptNumber>("nsigma") = value;
if(this->opt->hasOpt("paramsel.sigma") && value > 1.0)
{
std::cout << "Warning: ignoring previous values of the kernel parameter" << std::endl;
this->opt->template getOptAs<GurlsOptionsList>("paramsel")->removeOpt("sigma");
}
}
- Parameters:
-
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);
}
- Parameters:
-
Definition at line 147 of file wrapper.hpp.
{
if(this->opt->hasOpt("paramsel.sigma"))
this->opt->template getOptValue<OptNumber>("paramsel.sigma") = value;
else
{
GurlsOptionsList* paramsel = this->opt->template getOptAs<GurlsOptionsList>("paramsel");
paramsel->addOpt("sigma", new OptNumber(value));
}
setNSigma(1);
}
The documentation for this class was generated from the following files: