som_quality
Purpose
Calculates two quality measures for the given map.
Syntax
qe = som_quality(sM,sD);
qe = som_quality(sM,D);
[qe,te] = som_quality(...);
Description
This function measures the quality of the given map. The measures are
datadependent: they measure the map in terms of the given
data. Typically, the quality of the map is measured in terms of the
training data. The returned quality measures are average quantization
error and topographic error.
The issue of SOM quality is a complicated one. Typically two evaluation
criterias are used: resolution and topology preservation. There are
many ways to measure them. The ones implemented here were chosen for
their simplicity.
qe : Average distance between each data vector and its BMU.
Measures map resolution.
te : Topographic error, the proportion of all data vectors
for which first and second BMUs are not adjacent units.
Measures topology preservation.
NOTE: when calculating BMUs of data vectors, the mask of the given
map is used. The mask affects the quantization errors, too.
If you want the quantization errors without the weighting given
by the mask, you can use the following code:
bmus = som_bmus(sMap,D); % this uses the mask in finding the BMUs
for i=1:length(bmus),
dx = sMap.codebook(bmus(i),:)D(i,:); % m  x
dx(isnan(dx)) = 0; % remove NaNs
qerr(i) = sqrt(sum(dx.^2)); % euclidian distance
end
qe = mean(qerr); % average quantization error
Please note that you should _not_ trust the measures blindly. Generally,
both measures give the best results when the map has overfitted the
data. This may happen when the number of map units is as large or larger
than the number of training samples. Beware when you have such a case.
References
Kohonen, T., "SelfOrganizing Map", 2nd ed., SpringerVerlag,
Berlin, 1995, pp. 113.
Kiviluoto, K., "Topology Preservation in SelfOrganizing Maps",
in the proceeding of International Conference on Neural
Networks (ICNN), 1996, pp. 294299.
Input arguments
sMap (struct) Map struct.
D The data to be used.
(matrix) A data matrix, size dlen x dim.
(struct) A data struct.
Output arguments
qe (scalar) mean quantization error
te (scalar) topographic error
Examples
qe = som_quality(sMap,D);
[qe,te] = som_quality(sMap,sD);
See also
som_bmus
 Find BMUs for the given set of data vectors.
