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

License | BSD-style |

Maintainer | amy@nualeargais.ie |

Stability | experimental |

Portability | portable |

Safe Haskell | Safe-Inferred |

Language | Haskell98 |

A module containing private `DSOM`

internals. Most developers should
use `DSOM`

instead. This module is subject to change without notice.

- data DSOM gm k p = DSOM {}
- toGridMap :: GridMap gm p => DSOM gm k p -> gm p
- adjustNode :: (Pattern p, FiniteGrid (gm p), GridMap gm p, k ~ Index (gm p), Ord k, k ~ Index (BaseGrid gm p), Num (Metric p), Fractional (Metric p)) => gm p -> (Metric p -> Metric p -> Metric p) -> p -> k -> k -> p -> p
- scaleDistance :: (Num a, Fractional a) => Int -> Int -> a
- 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
- justTrain :: (Pattern p, FiniteGrid (gm p), GridMap gm p, Num (Metric p), Ord (Metric p), Ord (Index (gm p)), GridMap gm (Metric p), Fractional (Metric p), Index (BaseGrid gm (Metric p)) ~ Index (gm p), Index (BaseGrid gm p) ~ Index (gm p)) => DSOM gm t p -> p -> DSOM gm (Index (gm p)) 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

# Documentation

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 Direction (DSOM gm k p) = Direction (gm p) | |

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

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

Extracts the grid and current models from the DSOM.

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

scaleDistance :: (Num a, Fractional a) => Int -> Int -> a Source

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.

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

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.