SomParam-class {bluster} | R Documentation

## Clustering with self-organizing maps

### Description

Use the self-organizing map implementation in the kohonen package to cluster observations into the specified number of nodes. Note that this requires the installation of the kohonen package.

### Usage

    SomParam(
      centers,
      dim.ratio = 1,
      topo = "rectangular",
      neighbourhood.fct = "bubble",
      toroidal = FALSE,
      rlen = 100,
      alpha = c(0.05, 0.01),
      radius = NULL,
      dist.fct = "sumofsquares"
    )

    ## S4 method for signature 'ANY,SomParam'
    clusterRows(x, BLUSPARAM, full = FALSE)

### Arguments

`centers` | An integer scalar specifying the number of centers. Alternatively, a function that takes the number of observations and returns the number of centers.
`dim.ratio` | A positive numeric scalar in specifying how `centers` should be distributed between the `x` and `y` dimensions. Defaults to equal distribution, i.e., both dimensions will be of length equal to the square root of `centers`. Values above 1 will distribute more nodes to `x` while values below 1 will distribute mode nodes to `y`.
`topo, neighbourhood.fct, toroidal` | Further arguments to pass to the `somgrid` function in the kohonen package.
`rlen, alpha, radius, dist.fct` | Further arguments to pass to the `som` function in the kohonen package.
`x` | A numeric matrix-like object where rows represent observations and columns represent variables.
`BLUSPARAM` | A SomParam object.
`full` | Logical scalar indicating whether the full SOM statistics should be returned.

### Details

This class usually requires the user to specify the number of clusters beforehand. However, we can also allow the number of clusters to vary as a function of the number of observations. The latter is occasionally useful, e.g., to allow the clustering to automatically become more granular for large datasets.

Note that the final number of clusters may not be exactly equal to `centers`, depending on how `dim.ratio` is specified. For example, if `centers` is a perfect square and `dim.ratio=1`, we will get exactly the requested number of points.

To modify an existing SomParam object `x`, users can simply call `x[[i]]` or `x[[i]] <- value` where `i` is any argument used in the constructor.

For `radius`, a value of `NULL` means that the default argument in the `som` function signature is used. This is are data-dependent and so cannot be specified during construction of the SomParam object.

For `dist.fct`, users can specify any string that can be used in the `dist.fcts` arguments in `som`. In practice, the only real alternative is `"manhattan"`.

### Value

The `SomParam` constructor will return a SomParam object with the specified parameters.

The `clusterRows` method will return a factor of length equal to `nrow(x)` containing the cluster assignments. If `full=TRUE`, a list is returned with `clusters` (the factor, as above) and `objects` (a list containing `som`, the direct output of `som`).

### Author(s)

Aaron Lun

### See Also

`som` from the kohonen package, which does all of the heavy lifting.

FixedNumberParam, the parent of the SomParam class.

### Examples

    clusterRows(iris[,1:4], SomParam(centers=16))
    clusterRows(iris[,1:4], SomParam(centers=12, dim.ratio=3/4))

[Package bluster version 1.4.0 Index]