Copyright | (c) Amy de Buitléir 2012-2018 |
---|---|
License | BSD-style |
Maintainer | amy@nualeargais.ie |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
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.
Synopsis
- data DSOM gm x k p = DSOM {
- gridMap :: gm p
- learningRate :: x -> x -> x -> x
- difference :: p -> p -> x
- makeSimilar :: p -> x -> p -> p
- toGridMap :: GridMap gm p => DSOM gm x k p -> gm p
- rougierLearningFunction :: (Eq a, Ord a, Floating a) => a -> a -> a -> a -> a -> a
- trainNeighbourhood :: (FiniteGrid (gm p), GridMap gm p, k ~ Index (gm p), k ~ Index (BaseGrid gm p), Ord k, Num x, Fractional x) => DSOM gm x t p -> k -> p -> DSOM gm x 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
, andadjustWithKey
do not increment the counter. You can do so manually withincrementCounter
. - The functions
map
andmapWithKey
are not implemented (they just return anerror
). It would be problematic to implement them because the input DSOM and the output DSOM would have to have the sameMetric
type.
DSOM | |
|
Instances
(GridMap gm p, k ~ Index (BaseGrid gm p), FiniteGrid (gm p), GridMap gm x, k ~ Index (gm p), k ~ Index (gm x), k ~ Index (BaseGrid gm x), Ord k, Ord x, Num x, Fractional x) => Classifier (DSOM gm) x k p Source # | |
Defined in Data.Datamining.Clustering.DSOMInternal toList :: DSOM gm x k p -> [(k, p)] Source # numModels :: DSOM gm x k p -> Int Source # models :: DSOM gm x k p -> [p] Source # differences :: DSOM gm x k p -> p -> [(k, x)] Source # classify :: DSOM gm x k p -> p -> k Source # train :: DSOM gm x k p -> p -> DSOM gm x k p Source # trainBatch :: DSOM gm x k p -> [p] -> DSOM gm x k p Source # classifyAndTrain :: DSOM gm x k p -> p -> (k, DSOM gm x k p) Source # diffAndTrain :: DSOM gm x k p -> p -> ([(k, x)], DSOM gm x k p) Source # reportAndTrain :: DSOM gm x k p -> p -> (k, [(k, x)], DSOM gm x k p) Source # | |
Foldable gm => Foldable (DSOM gm x k) Source # | |
Defined in Data.Datamining.Clustering.DSOMInternal fold :: Monoid m => DSOM gm x k m -> m # foldMap :: Monoid m => (a -> m) -> DSOM gm x k a -> m # foldr :: (a -> b -> b) -> b -> DSOM gm x k a -> b # foldr' :: (a -> b -> b) -> b -> DSOM gm x k a -> b # foldl :: (b -> a -> b) -> b -> DSOM gm x k a -> b # foldl' :: (b -> a -> b) -> b -> DSOM gm x k a -> b # foldr1 :: (a -> a -> a) -> DSOM gm x k a -> a # foldl1 :: (a -> a -> a) -> DSOM gm x k a -> a # toList :: DSOM gm x k a -> [a] # null :: DSOM gm x k a -> Bool # length :: DSOM gm x k a -> Int # elem :: Eq a => a -> DSOM gm x k a -> Bool # maximum :: Ord a => DSOM gm x k a -> a # minimum :: Ord a => DSOM gm x k a -> a # | |
(Foldable gm, GridMap gm p, FiniteGrid (BaseGrid gm p)) => GridMap (DSOM gm x k) p Source # | |
Defined in Data.Datamining.Clustering.DSOMInternal (!) :: (k0 ~ Index (BaseGrid (DSOM gm x k) p), Ord k0) => DSOM gm x k p -> k0 -> p # toMap :: k0 ~ Index (BaseGrid (DSOM gm x k) p) => DSOM gm x k p -> Map k0 p # toGrid :: DSOM gm x k p -> BaseGrid (DSOM gm x k) p # toList :: k0 ~ Index (BaseGrid (DSOM gm x k) p) => DSOM gm x k p -> [(k0, p)] # lookup :: (k0 ~ Index (BaseGrid (DSOM gm x k) p), Ord k0) => k0 -> DSOM gm x k p -> Maybe p # insert :: (k0 ~ Index (BaseGrid (DSOM gm x k) p), Ord k0) => k0 -> p -> DSOM gm x k p -> DSOM gm x k p # insertWith :: (k0 ~ Index (BaseGrid (DSOM gm x k) p), Ord k0) => (p -> p -> p) -> k0 -> p -> DSOM gm x k p -> DSOM gm x k p # insertWithKey :: (k0 ~ Index (BaseGrid (DSOM gm x k) p), Ord k0) => (k0 -> p -> p -> p) -> k0 -> p -> DSOM gm x k p -> DSOM gm x k p # insertLookupWithKey :: (k0 ~ Index (BaseGrid (DSOM gm x k) p), Ord k0) => (k0 -> p -> p -> p) -> k0 -> p -> DSOM gm x k p -> (Maybe p, DSOM gm x k p) # delete :: (k0 ~ Index (BaseGrid (DSOM gm x k) p), Ord k0) => k0 -> DSOM gm x k p -> DSOM gm x k p # adjust :: (k0 ~ Index (BaseGrid (DSOM gm x k) p), Ord k0) => (p -> p) -> k0 -> DSOM gm x k p -> DSOM gm x k p # adjustWithKey :: (k0 ~ Index (BaseGrid (DSOM gm x k) p), Ord k0) => (k0 -> p -> p) -> k0 -> DSOM gm x k p -> DSOM gm x k p # alter :: (k0 ~ Index (BaseGrid (DSOM gm x k) p), Ord k0) => (Maybe p -> Maybe p) -> k0 -> DSOM gm x k p -> DSOM gm x k p # findWithDefault :: (k0 ~ Index (BaseGrid (DSOM gm x k) p), Ord k0) => p -> k0 -> DSOM gm x k p -> p # keys :: (k0 ~ Index (BaseGrid (DSOM gm x k) p), Ord k0) => DSOM gm x k p -> [k0] # elems :: DSOM gm x k p -> [p] # map :: (GridMap (DSOM gm x k) v2, Index (BaseGrid (DSOM gm x k) p) ~ Index (BaseGrid (DSOM gm x k) v2)) => (p -> v2) -> DSOM gm x k p -> DSOM gm x k v2 # mapWithKey :: (k0 ~ Index (BaseGrid (DSOM gm x k) p), k0 ~ Index (BaseGrid (DSOM gm x k) v2), GridMap (DSOM gm x k) v2) => (k0 -> p -> v2) -> DSOM gm x k p -> DSOM gm x k v2 # filter :: (p -> Bool) -> DSOM gm x k p -> DSOM gm x k p # filterWithKey :: k0 ~ Index (BaseGrid (DSOM gm x k) p) => (k0 -> p -> Bool) -> DSOM gm x k p -> DSOM gm x k p # | |
Generic (DSOM gm x k p) Source # | |
NFData (gm p) => NFData (DSOM gm x k p) Source # | |
Defined in Data.Datamining.Clustering.DSOMInternal | |
Grid (gm p) => Grid (DSOM gm x k p) Source # | |
Defined in Data.Datamining.Clustering.DSOMInternal indices :: DSOM gm x k p -> [Index (DSOM gm x k p)] # distance :: DSOM gm x k p -> Index (DSOM gm x k p) -> Index (DSOM gm x k p) -> Int # minDistance :: DSOM gm x k p -> [Index (DSOM gm x k p)] -> Index (DSOM gm x k p) -> Int # neighbours :: DSOM gm x k p -> Index (DSOM gm x k p) -> [Index (DSOM gm x k p)] # neighboursOfSet :: DSOM gm x k p -> [Index (DSOM gm x k p)] -> [Index (DSOM gm x k p)] # neighbour :: DSOM gm x k p -> Index (DSOM gm x k p) -> Direction (DSOM gm x k p) -> Maybe (Index (DSOM gm x k p)) # numNeighbours :: DSOM gm x k p -> Index (DSOM gm x k p) -> Int # contains :: DSOM gm x k p -> Index (DSOM gm x k p) -> Bool # tileCount :: DSOM gm x k p -> Int # null :: DSOM gm x k p -> Bool # nonNull :: DSOM gm x k p -> Bool # edges :: DSOM gm x k p -> [(Index (DSOM gm x k p), Index (DSOM gm x k p))] # viewpoint :: DSOM gm x k p -> Index (DSOM gm x k p) -> [(Index (DSOM gm x k p), Int)] # isAdjacent :: DSOM gm x k p -> Index (DSOM gm x k p) -> Index (DSOM gm x k p) -> Bool # adjacentTilesToward :: DSOM gm x k p -> Index (DSOM gm x k p) -> Index (DSOM gm x k p) -> [Index (DSOM gm x k p)] # minimalPaths :: DSOM gm x k p -> Index (DSOM gm x k p) -> Index (DSOM gm x k p) -> [[Index (DSOM gm x k p)]] # directionTo :: DSOM gm x k p -> Index (DSOM gm x k p) -> Index (DSOM gm x k p) -> [Direction (DSOM gm x k p)] # defaultMinDistance :: DSOM gm x k p -> [Index (DSOM gm x k p)] -> Index (DSOM gm x k p) -> Int # defaultNeighbours :: DSOM gm x k p -> Index (DSOM gm x k p) -> [Index (DSOM gm x k p)] # defaultNeighboursOfSet :: DSOM gm x k p -> [Index (DSOM gm x k p)] -> [Index (DSOM gm x k p)] # defaultNeighbour :: DSOM gm x k p -> Index (DSOM gm x k p) -> Direction (DSOM gm x k p) -> Maybe (Index (DSOM gm x k p)) # defaultTileCount :: DSOM gm x k p -> Int # defaultEdges :: DSOM gm x k p -> [(Index (DSOM gm x k p), Index (DSOM gm x k p))] # defaultIsAdjacent :: DSOM gm x k p -> Index (DSOM gm x k p) -> Index (DSOM gm x k p) -> Bool # defaultAdjacentTilesToward :: DSOM gm x k p -> Index (DSOM gm x k p) -> Index (DSOM gm x k p) -> [Index (DSOM gm x k p)] # defaultMinimalPaths :: DSOM gm x k p -> Index (DSOM gm x k p) -> Index (DSOM gm x k p) -> [[Index (DSOM gm x k p)]] # | |
type BaseGrid (DSOM gm x k) p Source # | |
Defined in Data.Datamining.Clustering.DSOMInternal | |
type Rep (DSOM gm x k p) Source # | |
Defined in Data.Datamining.Clustering.DSOMInternal type Rep (DSOM gm x k p) = D1 (MetaData "DSOM" "Data.Datamining.Clustering.DSOMInternal" "som-10.1.8-4U7idyllz4eEJA79g8KqEw" False) (C1 (MetaCons "DSOM" PrefixI True) ((S1 (MetaSel (Just "gridMap") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (gm p)) :*: S1 (MetaSel (Just "learningRate") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (x -> x -> x -> x))) :*: (S1 (MetaSel (Just "difference") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (p -> p -> x)) :*: S1 (MetaSel (Just "makeSimilar") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (p -> x -> p -> p))))) | |
type Direction (DSOM gm x k p) Source # | |
Defined in Data.Datamining.Clustering.DSOMInternal | |
type Index (DSOM gm x k p) Source # | |
Defined in Data.Datamining.Clustering.DSOMInternal |
Deconstruction
toGridMap :: GridMap gm p => DSOM gm x k p -> gm p Source #
Extracts the grid and current models from the DSOM.
Learning functions
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 pr
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.
Advanced control
trainNeighbourhood :: (FiniteGrid (gm p), GridMap gm p, k ~ Index (gm p), k ~ Index (BaseGrid gm p), Ord k, Num x, Fractional x) => DSOM gm x t p -> k -> p -> DSOM gm x 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.