MeanSquaredError Class Reference

Calculates the mean squared error. More...

#include <MeanSquaredError.h>

Inheritance diagram for MeanSquaredError:

ErrorFunction

List of all members.

Public Member Functions

double error (Model &model, const Array< double > &input, const Array< double > &target)
 Calculates the mean squared error between the output and the target vector.
double errorDerivative (Model &model, const Array< double > &input, const Array< double > &target, Array< double > &derivative)
 Calculates the derivatives of the mean squared error with respect to the parameters ModelInterface::w.


Detailed Description

Calculates the mean squared error.

These methods can be used as error measure model for the learning process.

Author:
B. Sendhoff
Date:
1999
Changes:
none
Status:
stable
Examples:

LinearRegressionTest.cpp, simpleFFNet.cpp, simpleRBFNet.cpp, and SVMregression.cpp.

Definition at line 71 of file MeanSquaredError.h.


Member Function Documentation

double MeanSquaredError::error ( Model model,
const Array< double > &  input,
const Array< double > &  target 
) [inline, virtual]

Calculates the mean squared error between the output and the target vector.

Measures the euklidian distance between the model output model(in), calculated from the input vector in, and the target vector target. The result is then normalized to the number of output neurons. Consider the case of a N-dimensional output vector, i.e. a neural network with N output neurons, and a set of P patterns. In this case the function calculates

\[ E = \frac{1}{p \cdot N} \sum_{p=1}^P\sum_{i=1}^N(model(output)_{ip} - target_{ip})^{2} \]

Parameters:
input Input vector for the model.
target Target vector.
Returns:
The mean squared error E.
Author:
B. Sendhoff
Date:
1999
Changes
C. Igel, M. Toussaint, 2001-09-13:
Normalising now with no. of output neurons and no. of patterns.
Status
stable

Implements ErrorFunction.

Examples:
LinearRegressionTest.cpp, simpleFFNet.cpp, simpleRBFNet.cpp, and SVMregression.cpp.

Definition at line 107 of file MeanSquaredError.h.

References Model::model().

double MeanSquaredError::errorDerivative ( Model model,
const Array< double > &  input,
const Array< double > &  target,
Array< double > &  derivative 
) [inline, virtual]

Calculates the derivatives of the mean squared error with respect to the parameters ModelInterface::w.

According to the equation in the description for the function error the derivatives of the mean squared error can be calculated with

\[ \frac{E}{w_j} = \frac{2}{p \cdot N} \sum_{p=1}^P \sum_{i=1}^N (model(in)_{ip} - out_{ip}) \frac{model(in)_{ip}}{w_j} \]

The results are written to the vector ModelInterface::dedw.

Usually, as a byproduct of the calculation of the derivative one gets the the error $E$ itself very efficiently. Therefore, the method error gives back this value. This additional effect can be switched of by means of the third parameter (returnError = false).

Parameters:
input Input vector for the model.
target The target vector.
returnError Determines whether or not to calculate the error itself. By default the error is calculated.
Returns:
The error E if returnError is set to "true", "-1" otherwise.
Author:
B. Sendhoff
Date:
1999
Changes
C. Igel, M. Toussaint, 2001-09-13:
Normalising now with no. of output neurons and no. of patterns.
Status
stable

Reimplemented from ErrorFunction.

Definition at line 169 of file MeanSquaredError.h.

References Model::getParameterDimension(), i, and Model::modelDerivative().


The documentation for this class was generated from the following file: