prototype.distances: Compute distances between neighbouring prototypes in a fitted...

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Compute the distances between the prototypes of a fitted Self-Organising Map (SOM) for neighbouring units in the prior structure.

Usage

1
2
3
4
5
prototype.distances(som, check = FALSE)
## S3 method for class 'sompdist'
as.matrix(x, extended = TRUE, ...)
## S3 method for class 'sompdist'
as.dist(x, FUN = NULL)

Arguments

som

an object of class "som"

check

logical, with default to FALSE. If TRUE, the underlying prototype distance calculation function will stop if it encounters non negligible negative values (see details).

x

an object of class "sompdist"

extended

logical. If TRUE the distance matrix or object build from neighbouring prototypes is extended to cover all pairs of prototypes via a graph based approach (see below for details). If FALSE only neighbouring prototypes are considered

...

not used

FUN

not used

Details

The as.matrix method can be used to convert a distance matrix (an object of class"sompdist") into a classical distance matrix as obtained via the as.matrix applied to objects of class "dist" (see dist). However, the distance matrix obtained this way is not the matrix of the Euclidean distances between the prototypes of the SOM: only the distances between direct neighbours in the grid are considered (see as.dist.somnum, as.dist.relationalsom and as.dist.kernelsom for all pairwise distances between prototypes). There are used as edge lengths (or weights) for an undirected graph whose nodes are the units and which has edges only between direct neighbours. If the as.matrix method is called with extended=TRUE (the default value), then this graph is used to define a distance between any pair of nodes in the grid as the length of the shortest path between the considered node (this is the unit distance used in error.kaskilagus). If the method is used with extended=FALSE, then the missing distances (i.e. between non direct neighbours) are unknown (value NA).

If the som is a relational SOM, the "distances" between prototypes are computed via the relational extension which can lead under some circumstances to negative values. If the check parameter is set to TRUE, the code will stop in this circumstance. This should never happen in the case of the kernel SOM. However, no effort is made to verify that the kernel matrix is non negative and therefore, negative values can also be found in this case. As in the relational case, a TRUE value for check asks to the code to stop in case of negative values.

The as.dist method can be used to convert a distance matrix (an object of class "sompdist") into an object of class "dist". The extension procedure described above is always used.

Visualisation of the obtained distance matrix can be done directly with the plot.sompdist method or indirectly via the distance.grid function.

Value

prototype.distances returns an object of class"sompdist", a list with components:

pdist

a matrix containing the distances between prototypes. It has one row for each prototype and 6 or 8 columns, depending on the topology of the prior structure (6 for a hexagonal grid and 8 for a rectangular one). When a prototype has not the maximum number of neighbours because of its position in the grid, the corresponding entries are encoded with NA.

somgrid

an object of class "somgrid", the prior structure used for fitting the som object

as.matrix returns a square matrix and as.dist an object of class "dist".

Note

This function applies to standard numerical Self-Organising Map but also to relational SOM. In the first case, the distances between prototypes is the standard Euclidean distance. In the second case, the distance is obtained via the relational formula which can lead to negative values. When such values are obtained, they are replaced by zeros and a warning is generated.

Author(s)

Fabrice Rossi

References

Kaski, S. and Lagus, K. (1996) Comparing self-organizing maps, in: C. von der Malsburg, W. von Seelen, J. Vorbrüggen, B. Sendhoff (eds.), Proceedings of International Conference on Artificial Neural Networks (ICANN'96, Bochum, Germany), vol. 1112 of Lecture Notes in Computer Science, Springer, pp. 809–814.

See Also

See distance.grid for converting the prototypes distances into a grid of values that can be easily displayed, plot.sompdist and umatrix for simple visualisations of those distances and error.kaskilagus for an error measure based on prototypes distances. See as.dist.somnum for all pairwise distances between prototypes.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data(iris)
# scaling
data <- scale(iris[1:4])

# a small hexagonal grid
sg <- somgrid(xdim=8,ydim=8,topo="hex")

# fit the SOM
som <- batchsom(data,sg)

# compute the distance
pdist <- prototype.distances(som)

# crude visualisation
image(as.matrix(pdist))

yasomi documentation built on May 2, 2019, 5:59 p.m.