Copyright  (c) Amy de Buitléir 20122015 

License  BSDstyle 
Maintainer  amy@nualeargais.ie 
Stability  experimental 
Portability  portable 
Safe Haskell  Safe 
Language  Haskell98 
A Selforganising Set (SOS). An SOS maps input patterns onto a set, where each element in the set is a model of the input data. An SOS is like a Kohonen Selforganising Map (SOM), except:
 Instead of a grid, it uses a simple set of unconnected models. Since the models are unconnected, only the model that best matches the input is ever updated. This makes it faster, however, topological relationships within the input data are not preserved.
 New models are created onthefly when no existing model is similar enough to an input pattern. If the SOS is at capacity, the least useful model will be deleted.
This implementation supports the use of nonnumeric patterns.
In layman's terms, a SOS can be useful when you you want to build a set of models on some data. A tutorial is available at https://github.com/mhwombat/som/wiki.
References:
 de Buitléir, Amy, Russell, Michael and Daly, Mark. (2012). Wains: A patternseeking artificial life species. Artificial Life, 18 (4), 399423.
 Kohonen, T. (1982). Selforganized formation of topologically correct feature maps. Biological Cybernetics, 43 (1), 59–69.
 data SOS t x k p = SOS {
 toMap :: Map k (p, t)
 learningRate :: t > x
 maxSize :: Int
 diffThreshold :: x
 difference :: p > p > x
 makeSimilar :: p > x > p > p
 nextIndex :: k
 makeSOS :: Bounded k => (t > x) > Int > x > (p > p > x) > (p > x > p > p) > SOS t x k p
 time :: Num t => SOS t x k p > t
 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
 exponential :: (Floating a, Integral t) => a > a > t > a
 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
Construction
A Simplified SelfOrganising 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 > (p > p > x) > (p > x > p > p) > SOS t x k p Source
Deconstruction
time :: Num t => SOS t x k p > t Source
The current "time" (number of times the SOS has been trained).
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).
Learning and classification
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
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.