som module

class som.SOM(graph, neighbourhood_function=None, neighbourhood_depth=2, learning_rate=0.1, iterations=10)

Bases: object

A class to apply the Self-Organising-Map algorithm over a given graph.

Parameters
  • graph – The graph to apply the Self-Organising-Map algorithm over, (type Graph from this package)

  • neighbourhood_function – Optional, default = None - The neighbourhood weight function, takes in depth (integer) and returns the weight for that given depth (float). If None simple_neighbourhood_function is used.

  • neighbourhood_depth – Optional, default = 2 - The maximum neighbourhood depth to consider.

  • learning_rate – Optional, default = 0.1 - The rate at which the graph updates over each iteration.

  • iterations – Optional, default = 10 - The amount of iteration the SOM algorithm will take.

fit(data)

Fits the SOM class to the given dataset.

Parameters

data – List of coordinate tuples.

Returns

This class instance.

transform(data)

Applies the self-organising-map algorithm over a given dataset and graph. The initially given graph will be altered after running transform().

Parameters

data – List of coordinate tuples.

Returns

The altered graph.

som.simple_neighbourhood_function(depth)

A simple example neighbourhood weight function for use with the SOM class.

Parameters

depth – The depth of the neighbourhood to get the weight for (Integer).

Returns

A weight for the neighbourhood at a given depth (1 if depth is 1, 0.2 if depth is 2, 0 otherwise).