#include <lwpr.hh>
Public Member Functions | |
LWPR_Object (int nIn, int nOut) | |
Creates an LWPR_Object for the given input and output dimensionalities. | |
LWPR_Object (const LWPR_Object &otherObj) | |
Creates a copy of an LWPR_Object. | |
LWPR_Object (const char *filename) | |
Creates an LWPR_Object from a binary file, or if compiled with support for EXPAT, an XML file. | |
~LWPR_Object () | |
Destroys an LWPR_Object and disposes allocated memory. | |
int | writeXML (const char *filename) |
Write the model to an XML file. | |
int | writeBinary (const char *filename) |
Write the model to a binary file. | |
doubleVec | update (const doubleVec &x, const doubleVec &y) |
Updates an LWPR model with a given input/output pair (x,y). | |
doubleVec | predict (const doubleVec &x, double cutoff=0.001) |
Computes the prediction of an LWPR model given an input vector x. | |
doubleVec | predict (const doubleVec &x, doubleVec &confidence, double cutoff=0.001) |
Computes the prediction of an LWPR model given an input vector x. Also computes confidence bounds per output dimension. | |
doubleVec | predict (const doubleVec &x, doubleVec &confidence, doubleVec &maxW, double cutoff=0.001) |
Computes the prediction of an LWPR model given an input vector x. Also computes confidence bounds and maximal activation per output dimension. | |
void | setInitD (double delta) |
Sets a spherical initial distance metric. | |
void | setInitD (const doubleVec &initD) |
Sets a diagonal or full initial distance metric. | |
void | setInitAlpha (double alpha) |
Sets init_alpha (learning rate for 2nd order distance metric updates). | |
void | wGen (double w_gen) |
Sets w_gen (threshold for adding new receptive fields). | |
void | wPrune (double w_prune) |
Sets w_prune (threshold for removing a receptive field). | |
void | penalty (double pen) |
Sets penalty (pre-factor for smoothing term in distance metric updates). | |
void | initLambda (double iLam) |
Sets initial forgetting factor. | |
void | tauLambda (double tLam) |
Sets annealing rate for forgetting factor. | |
void | finalLambda (double fLam) |
Sets final forgetting factor. | |
void | initS2 (double init_s2) |
Sets initial value for covariance computation SSs2. | |
void | updateD (bool update) |
Determines whether distance matrix updates are to be performed. | |
void | diagOnly (bool dOnly) |
Determines whether distance matrices should be treaded as diagonal-only. | |
void | useMeta (bool meta) |
Determines whether 2nd order distance matrix updates are to be performed. | |
void | metaRate (double rate) |
Sets the learning rate for 2nd order distance matrix updates. | |
void | kernel (LWPR_Kernel kern) |
Sets the kernel to be used in the LWPR model. | |
void | kernel (const char *str) |
Sets the kernel (either "Gaussian" or "BiSquare") to be used in the LWPR model. | |
int | nData () const |
Returns the number of training data the model has seen. | |
int | nIn () const |
Returns the input dimensionality. | |
int | nOut () const |
Returns the output dimensionality. | |
double | wGen () const |
Returns w_gen (threshold for adding new receptive fields). | |
double | wPrune () const |
Returns w_prune (threshold for removing a receptive field). | |
double | penalty () const |
Returns penalty (pre-factor for smoothing term in distance metric updates). | |
double | initLambda () const |
Returns initial forgetting factor. | |
double | tauLambda () const |
Returns annealing rate for forgetting factor. | |
double | finalLambda () const |
Returns final forgetting factor. | |
double | initS2 () const |
Returns initial value for the covariance computation SSs2. | |
bool | updateD () |
Returns whether distance matrix updates are performed. | |
bool | diagOnly () |
Returns whether distance matrices are treaded as diagonal-only. | |
bool | useMeta () |
Returns whether 2nd order distance matrix updates are performed. | |
double | metaRate () |
Returns learning rate for 2nd order distance matrix updates. | |
LWPR_Kernel | kernel () |
Returns the kernel. | |
doubleVec | meanX () |
Returns the mean of all input samples the model has seen. | |
doubleVec | varX () |
Returns the variance of all input samples the model has seen. | |
void | normIn (const doubleVec &norm) |
Sets the input normalisation (expected scale or standard deviation of input data. | |
doubleVec | normIn () const |
Returns the input normalisation factors. | |
void | normOut (const doubleVec &norm) |
Sets the output normalisation (expected scale or standard deviation of output data. | |
doubleVec | normOut () const |
Returns the output normalisation factors. | |
int | numRFS (int outDim) |
Returns the number of receptive fields for output dimension "outDim". | |
std::vector< int > | numRFS () |
Returns the number of receptive fields for all output dimensions. | |
LWPR_ReceptiveFieldObject | getRF (int outDim, int index) const |
Returns a wrapper object for inspecting a receptive field. | |
Data Fields | |
LWPR_Model | model |
Underlying C structure. |
LWPR_Object::LWPR_Object | ( | int | nIn, | |
int | nOut | |||
) | [inline] |
Creates an LWPR_Object for the given input and output dimensionalities.
nIn | Desired input dimensionality | |
nOut | Desired output dimensionality |
References lwpr_init_model(), model, and LWPR_Exception::OUT_OF_MEMORY.
LWPR_Object::LWPR_Object | ( | const LWPR_Object & | otherObj | ) | [inline] |
Creates a copy of an LWPR_Object.
otherObj | LWPR_Object to be duplicated. |
References lwpr_duplicate_model(), model, and LWPR_Exception::OUT_OF_MEMORY.
LWPR_Object::LWPR_Object | ( | const char * | filename | ) | [inline] |
Creates an LWPR_Object from a binary file, or if compiled with support for EXPAT, an XML file.
filename | Name of file to read the model from |
References LWPR_Exception::IO_ERROR, lwpr_read_binary(), lwpr_read_xml(), and model.
LWPR_ReceptiveFieldObject LWPR_Object::getRF | ( | int | outDim, | |
int | index | |||
) | const [inline] |
Returns a wrapper object for inspecting a receptive field.
outDim | Desired output dimension | |
index | Index of the receptive field within that output dimension |
LWPR_Exception::OUT_OF_RANGE | if the parameters outDim and index are out of range |
References model, LWPR_Model::nOut, LWPR_SubModel::numRFS, LWPR_Exception::OUT_OF_RANGE, LWPR_SubModel::rf, and LWPR_Model::sub.
doubleVec LWPR_Object::predict | ( | const doubleVec & | x, | |
doubleVec & | confidence, | |||
doubleVec & | maxW, | |||
double | cutoff = 0.001 | |||
) | [inline] |
Computes the prediction of an LWPR model given an input vector x. Also computes confidence bounds and maximal activation per output dimension.
[in] | x | Input vector |
[out] | confidence | Vector to store the confidence bounds, will be resized if necessary |
[out] | maxW | Vector to store maximum activations, will be resized if necessary |
[in] | cutoff | A threshold parameter (default = 0.001). Receptive fields with activation below the cutoff are ignored |
LWPR_Exception::BAD_INPUT_DIM | if the parameter x does not match the model dimensions |
References LWPR_Exception::BAD_INPUT_DIM, lwpr_predict(), model, LWPR_Model::nIn, and LWPR_Model::nOut.
doubleVec LWPR_Object::predict | ( | const doubleVec & | x, | |
doubleVec & | confidence, | |||
double | cutoff = 0.001 | |||
) | [inline] |
Computes the prediction of an LWPR model given an input vector x. Also computes confidence bounds per output dimension.
[in] | x | Input vector |
[out] | confidence | Vector to store the confidence bounds, will be resized if necessary |
[in] | cutoff | A threshold parameter (default = 0.001). Receptive fields with activation below the cutoff are ignored |
LWPR_Exception::BAD_INPUT_DIM | if the parameter x does not match the model dimensions |
References LWPR_Exception::BAD_INPUT_DIM, lwpr_predict(), model, LWPR_Model::nIn, and LWPR_Model::nOut.
Computes the prediction of an LWPR model given an input vector x.
x | Input vector. | |
cutoff | A threshold parameter (default = 0.001). Receptive fields with activation below the cutoff are ignored |
LWPR_Exception::BAD_INPUT_DIM | if the parameter x does not match the model dimensions |
References LWPR_Exception::BAD_INPUT_DIM, lwpr_predict(), model, LWPR_Model::nIn, and LWPR_Model::nOut.
void LWPR_Object::setInitD | ( | const doubleVec & | initD | ) | [inline] |
Sets a diagonal or full initial distance metric.
initD | Either a vector with nIn elements, containing the diagonal of the desired distance metric, or a vector with nIn*nIn elements containing the complete distance matrix. |
LWPR_Exception::BAD_INIT_D | if the parameter initD gives rise to a non-positive matrix |
References LWPR_Exception::BAD_INIT_D, LWPR_Exception::BAD_INPUT_DIM, lwpr_set_init_D(), lwpr_set_init_D_diagonal(), model, and LWPR_Model::nIn.
void LWPR_Object::setInitD | ( | double | delta | ) | [inline] |
Sets a spherical initial distance metric.
delta | Width parameter, distance matrix will be delta * eye(nIn) |
LWPR_Exception::BAD_INIT_D | if the parameter delta is <= 0, giving rise to a non-positive matrix |
References LWPR_Exception::BAD_INIT_D, lwpr_set_init_D_spherical(), and model.
Updates an LWPR model with a given input/output pair (x,y).
x | Input vector | |
y | Output vector |
LWPR_Exception::OUT_OF_MEMORY | if a receptive field would have to be added, but memory could not be allocated | |
LWPR_Exception::BAD_INPUT_DIM | if the parameter x does not match the model dimensions | |
LWPR_Exception::BAD_OUTPUT_DIM | if the parameter y does not match the model dimensions |
References LWPR_Exception::BAD_INPUT_DIM, LWPR_Exception::BAD_OUTPUT_DIM, lwpr_update(), model, LWPR_Model::nIn, LWPR_Model::nOut, and LWPR_Exception::OUT_OF_MEMORY.
int LWPR_Object::writeBinary | ( | const char * | filename | ) | [inline] |
Write the model to a binary file.
filename | Name of the file, which will we overwritten if it already exists |
References lwpr_write_binary(), and model.
int LWPR_Object::writeXML | ( | const char * | filename | ) | [inline] |
Write the model to an XML file.
filename | Name of the file, which will we overwritten if it already exists |
References lwpr_write_xml(), and model.