Copyright | (c) Amy de Buitléir 2012-2014 |
---|---|

License | BSD-style |

Maintainer | amy@nualeargais.ie |

Stability | experimental |

Portability | portable |

Safe Haskell | Safe-Inferred |

Language | Haskell98 |

A modified Kohonen Self-organising Map (SOM) which supports a
time-independent learning function. (See

for a description of a SOM.)`SOM`

References:

- Rougier, N. & Boniface, Y. (2011). Dynamic self-organising map. Neurocomputing, 74 (11), 1840-1847.
- Kohonen, T. (1982). Self-organized formation of topologically correct feature maps. Biological Cybernetics, 43 (1), 59–69.

- data DSOM gm k p
- defaultDSOM :: (Eq (Metric p), Ord (Metric p), Floating (Metric p)) => gm p -> Metric p -> Metric p -> DSOM gm k p
- customDSOM :: gm p -> (Metric p -> Metric p -> Metric p -> Metric p) -> DSOM gm k p
- rougierLearningFunction :: (Eq a, Ord a, Floating a) => a -> a -> a -> a -> a -> a
- toGridMap :: GridMap gm p => DSOM gm k p -> gm p
- trainNeighbourhood :: (Pattern p, FiniteGrid (gm p), GridMap gm p, Num (Metric p), Ord k, k ~ Index (gm p), k ~ Index (BaseGrid gm p), Fractional (Metric p)) => DSOM gm t p -> k -> p -> DSOM gm k p

# Construction

A Self-Organising Map (DSOM).

Although `DSOM`

implements `GridMap`

, most users will only need the
interface provided by `Data.Datamining.Clustering.Classifier`

. If
you chose to use the `GridMap`

functions, please note:

- The functions
`adjust`

, and`adjustWithKey`

do not increment the counter. You can do so manually with`incrementCounter`

. - The functions
`map`

and`mapWithKey`

are not implemented (they just return an`error`

). It would be problematic to implement them because the input DSOM and the output DSOM would have to have the same`Metric`

type.

(GridMap gm p, (~) * k (Index (BaseGrid gm p)), Pattern p, FiniteGrid (gm p), GridMap gm (Metric p), (~) * k (Index (gm p)), (~) * k (Index (BaseGrid gm (Metric p))), Ord k, Ord (Metric p), Num (Metric p), Fractional (Metric p)) => Classifier (DSOM gm) k p | |

Foldable gm => Foldable (DSOM gm k) | |

(Foldable gm, GridMap gm p, FiniteGrid (BaseGrid gm p)) => GridMap (DSOM gm k) p | |

Grid (gm p) => Grid (DSOM gm k p) | |

type BaseGrid (DSOM gm k) p = BaseGrid gm p | |

type Index (DSOM gm k p) = Index (gm p) | |

type Direction (DSOM gm k p) = Direction (gm p) |

defaultDSOM :: (Eq (Metric p), Ord (Metric p), Floating (Metric p)) => gm p -> Metric p -> Metric p -> DSOM gm k p Source

Creates a classifier with a default (bell-shaped) learning
function. Usage is

, where:`defaultDSOM`

gm r w t

`gm`

- The geometry and initial models for this classifier.
A reasonable choice here is

, where`lazyGridMap`

g ps`g`

is a

, and`HexHexGrid`

`ps`

is a set of random patterns. `r`

- and [
`p`

] are the first two parameters to the

.`rougierLearningFunction`

customDSOM :: gm p -> (Metric p -> Metric p -> Metric p -> Metric p) -> DSOM gm k p Source

Creates a classifier with a custom learning function.
Usage is

, where:`customDSOM`

gm g

`gm`

- The geometry and initial models for this classifier.
A reasonable choice here is

, where`lazyGridMap`

g ps`g`

is a

, and`HexHexGrid`

`ps`

is a set of random patterns. `f`

- A function used to determine the learning rate (for adjusting the models in the classifier). This function will be invoked with three parameters. The first parameter will indicate how different the BMU is from the input pattern. The second parameter indicates how different the pattern of the node currently being trained is from the input pattern. The third parameter is the grid distance from the BMU to the node currently being trained, as a fraction of the maximum grid distance. The output is the learning rate for that node (the amount by which the node's model should be updated to match the target). The learning rate should be between zero and one.

rougierLearningFunction :: (Eq a, Ord a, Floating a) => a -> a -> a -> a -> a -> a Source

Configures a learning function that depends not on the time, but
on how good a model we already have for the target. If the
BMU is an exact match for the target, no learning occurs.
Usage is

, where `rougierLearningFunction`

r p`r`

is the
maximal learning rate (0 <= r <= 1), and `p`

is the elasticity.

NOTE: When using this learning function, ensure that
`abs . difference`

is always between 0 and 1, inclusive. Otherwise
you may get invalid learning rates.

# Deconstruction

toGridMap :: GridMap gm p => DSOM gm k p -> gm p Source

Extracts the grid and current models from the DSOM.

# Advanced control

trainNeighbourhood :: (Pattern p, FiniteGrid (gm p), GridMap gm p, Num (Metric p), Ord k, k ~ Index (gm p), k ~ Index (BaseGrid gm p), Fractional (Metric p)) => DSOM gm t p -> k -> p -> DSOM gm k p Source

Trains the specified node and the neighbourood around it to better
match a target.
Most users should use `train`

, which automatically determines
the BMU and trains it and its neighbourhood.