Copyright | (c) Amy de Buitléir 2012-2015 |
---|---|
License | BSD-style |
Maintainer | amy@nualeargais.ie |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell98 |
A module containing private SOS
internals. Most developers should
use SOS
instead. This module is subject to change without notice.
- exponential :: (Floating a, Integral t) => a -> a -> t -> a
- data SOS t x k p = SOS {
- toMap :: Map k (p, t)
- learningRate :: t -> x
- maxSize :: Int
- diffThreshold :: x
- allowDeletion :: Bool
- difference :: p -> p -> x
- makeSimilar :: p -> x -> p -> p
- nextIndex :: k
- makeSOS :: Bounded k => (t -> x) -> Int -> x -> Bool -> (p -> p -> x) -> (p -> x -> p -> p) -> SOS t x k p
- isEmpty :: SOS t x k p -> Bool
- numModels :: SOS t x k p -> Int
- modelMap :: SOS t x k p -> Map k p
- counterMap :: SOS t x k p -> Map k t
- models :: SOS t x k p -> [p]
- counters :: SOS t x k p -> [t]
- time :: Num t => SOS t x k p -> t
- addNode :: (Num t, Enum k, Ord k) => p -> SOS t x k p -> SOS t x k p
- deleteNode :: Ord k => k -> SOS t x k p -> SOS t x k p
- incrementCounter :: (Num t, Ord k) => k -> SOS t x k p -> SOS t x k p
- trainNode :: (Num t, Ord k) => SOS t x k p -> k -> p -> SOS t x k p
- leastUsefulNode :: Ord t => SOS t x k p -> k
- deleteLeastUsefulNode :: (Ord t, Ord k) => SOS t x k p -> SOS t x k p
- addModel :: (Num t, Ord t, Enum k, Ord k) => p -> SOS t x k p -> SOS t x k p
- classify :: (Num t, Ord t, Num x, Ord x, Enum k, Ord k) => SOS t x k p -> p -> (k, x, [(k, x)], SOS t x k p)
- train :: (Num t, Ord t, Num x, Ord x, Enum k, Ord k) => SOS t x k p -> p -> SOS t x k p
- trainBatch :: (Num t, Ord t, Num x, Ord x, Enum k, Ord k) => SOS t x k p -> [p] -> SOS t x k p
Documentation
exponential :: (Floating a, Integral t) => a -> a -> t -> a Source
A typical learning function for classifiers.
returns the learning rate at time exponential
r0 d tt
.
When t = 0
, the learning rate is r0
.
Over time the learning rate decays exponentially; the decay rate is
d
.
Normally the parameters are chosen such that:
- 0 < r0 < 1
- 0 < d
A Simplified Self-Organising Map (SOS).
t
is the type of the counter.
x
is the type of the learning rate and the difference metric.
k
is the type of the model indices.
p
is the type of the input patterns and models.
SOS | |
|
makeSOS :: Bounded k => (t -> x) -> Int -> x -> Bool -> (p -> p -> x) -> (p -> x -> p -> p) -> SOS t x k p Source
counterMap :: SOS t x k p -> Map k t Source
Returns a map from node ID to counter (number of times the node's model has been the closest match to an input pattern).
counters :: SOS t x k p -> [t] Source
Returns the current counters (number of times the node's model has been the closest match to an input pattern).
time :: Num t => SOS t x k p -> t Source
The current "time" (number of times the SOS has been trained).
addNode :: (Num t, Enum k, Ord k) => p -> SOS t x k p -> SOS t x k p Source
Adds a new node to the SOS.
deleteNode :: Ord k => k -> SOS t x k p -> SOS t x k p Source
Removes a node from the SOS. Deleted nodes are never re-used.
trainNode :: (Num t, Ord k) => SOS t x k p -> k -> p -> SOS t x k p Source
Trains the specified node to better match a target.
Most users should use
, which automatically determines
the BMU and trains it.train
leastUsefulNode :: Ord t => SOS t x k p -> k Source
classify :: (Num t, Ord t, Num x, Ord x, Enum k, Ord k) => SOS t x k p -> p -> (k, x, [(k, x)], SOS t x k p) Source
identifies the model classify
s ps
that most closely
matches the pattern p
.
If necessary, it will create a new node and model.
Returns the ID of the node with the best matching model,
the difference between the best matching model and the pattern,
the differences between the input and each model in the SOS,
and the (possibly updated) SOS.