table of figuresmihkel.org/failid/data mining.docx · web viewproject for mtat.03.183 data mining...

22
TARTU ÜLIKOOL MATEMAATIKAINFORMAATIKATEADUSKOND Arvutiteaduse instituut Kuido Külm & Mihkel Jõhvik Self-Organizing Maps – Training Visualization Tool Project for MTAT.03.183 Data Mining Tartu 2011

Upload: doanmien

Post on 30-Apr-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

TARTU ÜLIKOOLMATEMAATIKAINFORMAATIKATEADUSKOND

Arvutiteaduse instituut

Kuido Külm & Mihkel Jõhvik

Self-Organizing Maps – Training Visualization ToolProject for MTAT.03.183 Data Mining

Tartu 2011

Page 2: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

Table of contentsTable of figures.......................................................................................................................................3

Abstract..................................................................................................................................................4

1 Introduction.........................................................................................................................................5

2 Related Work.......................................................................................................................................6

3 Self-Organizing Maps...........................................................................................................................8

4 Implementation...................................................................................................................................9

5 Results...............................................................................................................................................12

5.1 Configuration..............................................................................................................................12

5.2 Visualization...............................................................................................................................12

6 Conclusion.........................................................................................................................................17

References............................................................................................................................................18

Appendix..............................................................................................................................................18

2

Page 3: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

Table of figuresFigure 1 - A screen capture of the wsom program in action [6].............................................................6Figure 2 - Tom Germano's Java applet in action.....................................................................................7Figure 3 - The results of JavaSOM in SVG format...................................................................................7Figure 4 - 8 colors mapped onto a 2D grid by a SOM [2]........................................................................8Figure 5- Graph of a discrete neighborhood function............................................................................9Figure 6 - Graph of a Gauss neighborhood function [3].......................................................................10Figure 7 - Graph of a mexican hat neighborhood function [4].............................................................10Figure 8 – Box plot of the iris data set..................................................................................................13Figure 9 - Scatterplot of the Iris data set..............................................................................................13Figure 10 - Neuron map of the Iris dataset...........................................................................................14Figure 11 - Weight change ratio whil training the Iris data set.............................................................14Figure 12 - Best matching units found while training on the Iris dataset.............................................15Figure 13 - Neuron heatmap from the Iris dataset...............................................................................15Figure 14- Weights change average of the Iris data set........................................................................16Figure 15 - Weights change graph of the Iris dataset...........................................................................16Figure 16 - Decreasing neighborhood radius........................................................................................16

3

Page 4: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

AbstractThis project is intended to help students better understand Self-Organizing Maps.  The main contribution is a program that allows training Self-Organizing Maps on structured datasets and vizualizing the steps taken by the algorithm and the resulting Self-Organizing Map. Chapters 3 and 4 of this project explain the theoretical aspects of SOMs and their implementation in a software project. Chapter 5 focuses on explaining different aspects of the related program.

4

Page 5: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

1 IntroductionSelf-Organizing Map (referenced as SOM from now on) is a computational method for the visualization and analysis of high dimensional data [1]. SOMs allow for higher dimensional data to be clustered and mapped onto a lower dimensional object, usually a 2-dimensional grid. They are a form of neural networks that use unsupervised learning. The SOM structure and algortihm is explained in more detail in chapter 3.

SOMs are used in many data organization tasks, such as categorizing images. While SOMs offer unsupervized learning, they often do not reach optimal distribution and require further specification and classification by an overseer. 

SOMs can be a difficult subject to comprehend and implement and some assistance in learning about SOMs might be required. In the opinion of the authors, vizualisation is a key factor in understanding how SOMs work and operate. There are many demos and videos of SOMs in action available on the Internet. Some of them are mentioned in Chapter 2. However few show any helpful information about how different variables within the algorithm act while training.

The goal of this project is to create a program that implements SOMs and allows for visualizing different aspects of the training process and the trained SOM.

5

Page 6: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

2 Related WorkMany different SOM visualization tools have been created for educational purposes. In this section we cover only those that are released under a public licence. 

Christian Borgelt has created a SOM visualization tool called wsom (or xsom for the Linux version) [6]. This tool allows viewing a grid of interconnected nodes training itself to organize itself into a rectangular 2D grid. The SOM being trained is redrawn after every cycle of the SOM algorithm, which creates an active view of the training process. This program does not characterize any other data about the SOM or its training process. Neither does this program allow loading different datasets for training. A screen capture of wsom in action can be seen on Figure 1.

Figure 1 - A screen capture of the wsom program in action [6]

Another illustrative program was created by Tom Germano, which uses colors with their three base components of red, green and blue as training data. It is a Java applett that can be configured to run different starting positions and at varying numbers of iterations. While different characteristics of the training process can be extrapolated from visual that the program provides while it’s running, it does not explicitly provide any information about how different aspects of the training algorithm change in time. Neither does this program allow loading different datasets for training. A screen capture of the program in action can be seen on Figure 2.

6

Page 7: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

Figure 2 - Tom Germano's Java applet in action

JavaSOM is a SOM vizualisation tool created by Tomi Suuronen for his Bachelor’s Thesis. It allows loading training data in XML format and the trained SOM can be saved into XML, SVG and PDF formats. The last two are presented as images. While this program allows different inputs for datasets, it does not show any information about the training process itself. A screen capture of the program’s results in SVG format can be seen on Figure 3.

Figure 3 - The results of JavaSOM in SVG format

As there are already different programs that show how a SOM organizes itself, we decided to focus on a slightly different area. Namely, how different elements of the SOM training algorithm act while the algorithm is running.

7

Page 8: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

3 Self-Organizing MapsSOMs consist of nodes or neurons. Each neuron has weight vectors attached to them. The dimensioanlity of the weight vector matches that of the data that the SOM will be trained on. If X1 , X2 ,.. Xn, where each X  is an element of a vector from the training data set, then the corresponding weight vector would be W 1 ,W 2 .. ,W n. Like all neural networks, SOMs need to be trained. The goal is to make them act a certan way, given a particular input. This is achieved by adjusting each nodes weight vectors to resemble those in the training data set.

SOMs utilize unsupervized learning. The general algorithm for training a SOM is as follows:

1. Initialize weights of each node2. Choose a vector from the training data3. Calculate which node has a weight vector that matches the input vector the best. This is also 

known as the best matching unit, or the BMU.4. Calculate the radius of the BMU.5. Alter the weights of all the nodes in radius of the BMU. This alteration is inversely related to 

the distance a node has from the BMU. The greater the distance, the less the weights are changed.

6. Adjust the learning rate and go to step 2 for N iterations.

Learning rate is decreased over time. This is to make sure that previous learned inputs aren’t discarded. The algorithm stops when a predefined number of iterations has been completed or the average change of weights per iteration drops below a certain predefined value (this value is from now on referred to as delta). As can be seen, no predefined target vectors are set, so the algortihm requires no other input aside from a set of training data.

The most common demonstration of this algorithm is plotting colors on a 2-dimensional grid. As colors consist of varying values of red, green and blue, the dimensionality of the data is reduced. An example of this is shown in Figure 4.

8

Page 9: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

Figure 4 - 8 colors mapped onto a 2D grid by a SOM [2]

4 ImplementationThe program that we chose to expand upon was Self-Organizing Feature Maps by Bashir Magomedov[8]. This was in part due to Kuido having extensive knowlede in C# in which the program was written in. It also proved to be a good basis to expand upon, as it already had limited SOM functionality and was released under the GPL31 licence.

The program was written in C#2 using Visual Studio 20103. The previous program used a 2-dimensional coordinate system [8]. The updated version will migrate to a 3-dimensional coordinate system. However, as no free 3-dimensional visualization component for C# could be found, all the graphs will still be presented in 2 dimensions.

4 different neighbourhood functions are implemented. Neighborhood functions calculate which node is within radius of the BMU and how much it’s weights should be changed.

Discrete function

The discrete function uses Euclidean distance to calculate it’s neighborhood. The resulting distance is 

compared to a constant and the distance is calculated using f ( x )=( 12 )b

, where b is the selected 

constant. A graph describing the function is shown on Figure 5.

1 http://www.opensource.org/licenses/gpl-3.0.html2 http://msdn.microsoft.com/en-us/vstudio/hh3885663 http://www.microsoft.com/visualstudio/en-us

9

Page 10: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

Figure 5- Graph of a discrete neighborhood function

10

Page 11: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

Gauss function

f ( x )=ae(−( x−b )2

2c2), where a is unity, b is the position of the winner neuron and c  is  a measure of 

width of the bell shape. A graph describing the function is shown on Figure 6.

Figure 6 - Graph of a Gauss neighborhood function [3]

Mexican hat

The Mexican hat function is defined as f ( x )=a(1−( x−bc )2)e

−12 ( x−bc )

2

, where a is unity, b is the 

position of the winner neuron and c  is  a measure of width of the bell shape. A graph describing the function is shown of Figure 7. 

Figure 7 - Graph of a mexican hat neighborhood function [4]

French(Bergere) hat

The French hat neighborhood is somewhat similar to the discrete neighborhood. It also uses predefined distances and Euclidean distance as the distance measurement. If the neuron is within a predefined distance from the BMU, it’s automatically regarded the same as the BMU. If it is within 3 

leghts of the predefined distance, the value drops to −( 13 ). After that, the value is 0.

11

Page 12: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

12

Page 13: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

Learning rate

There are a few different functions to calculate the learning rate, which is a function of time. The one used in this program is the simplest: the learning rate decreases inversely with iterations. That is, the learning rate is a linear function that is calculated by dividing the iteration number by a certain predefined value.

Delta

Delta is the average change of the node weights. Every iteration, each node’s weight changes are averaged. Then these averages are in turn added together and divided by the number of total nodes. This number is used to determine whether further learning is necessary or not. Menaing that the algorithm runs until the changes in weights becomes small and insignificant. 

13

Page 14: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

5 ResultsThe resulting program is released under the GPL3 licence4.

5.1 ConfigurationThe program can read plain text files formated with one data entry per line. It is also capable of reading lightweight WEKA files, which have the attributes declared at the beginning.

To facilitate the learning process, the resulting program can be run in 2 different ways. The first option is to run the training algorithm. This option automatically runs the algorithm and produces all the implemented graphs. The second option is to run the algorithm manually. This allows the operator to see how the results are formed and see intermediary steps in how the final trained SOM is formed. 

Other configuration options allow setting the number of maximum iterations and delta, the size of the neuron output layer, the attributes that will be shown on correlation graphs and the neighbourhood function used in calculating the radius of the best matching unit (see Chapter 4).

Correlation attributes are 2 attribites that can be chosen from all the available attributes the training data has. This setting affects what will be shown on some of the graphs produced during training. Other attributes will be taken into account when training the map, but will not be shown on certain graphs.

A checkbox titled visualization allows for some graph generating processes to be turned off for faster training. If the checkbox is not ticked, only the neuron map will be generated.

Further configuration is available via the included config file. It is an XML file which allows changing some parameters of the programs behaviour. These options include setting the minimum and maximum values for the number of allowed neurons and minimum and maximum values of the allowed delta.

5.2 VisualizationThe resulting program implements a few different graphs for characterizing the input data. Some of these are updated during training, which may impact the time it takes to complete training. The first is a box plot, which shows the minimum, maximum, median and upper and lower quartiles of the input data. An example of the program output is showed in Figure 8.

4 http://www.opensource.org/licenses/gpl-3.0.html

14

Page 15: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

Figure 8 – Box plot of the iris5 data set

A scatterplot is also constructed from the initial data. This shows the correlation of the 2 attributes selected as correlation attributes plotted on a 2-dimensional grid. The points on the plot are also colored to represent their classification into different clusters. A sample of the program output is shown in Figure 9 

Figure 9 - Scatterplot of the Iris data set

Once the SOM training algorithm has been run, more data becomes available. The program automatically switches to the neuron map in the main window. A neuron map shows the placement of neurons on a 2-dimensional grid after training. Each neuron is given coordinates in a 3-

5 http://archive.ics.uci.edu/ml/datasets/Iris

15

Page 16: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

dimensional system. As no free component for 3-dimensional visualization could be found, the resulting map is still plotted on a 2-dimensional space. A sample of the programs’ output can be seen on Figure 10. Clicking on an input in the inpiut vector list will highlight the node it was used to create. This highlighting can be seen on Figure 10 at the coordinates (8,1).

Figure 10 - Neuron map of the Iris dataset

Delta decreases as the number of iterations increases and the changes in weights become smaller. This is represented on the weights change ratio per iterations chart. The value of delta is plotted against iteration numbers to show how it decreases over time. A sample of the program output is shown in Figure 11.

Of note is that the following five charts are updated as the training process is happening. This makes for an interactive presentation of the training process.

Figure 11 - Weight change ratio whil training the Iris data set

Some nodes are selected as the BMU more often than others. This is shown on the best matching units graph. The number of wins can be configured to be represented by the size of the node’s dot, or explicitly written as a number. A sample of the program’s output can be seen in Figure 12.

16

Page 17: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

Figure 12 - Best matching units found while training on the Iris dataset

Neuron heatmap shows the average change of a neuron’s weight per iteration. Once the heatmap starts showing distinct lines, the training process is nearly finished. An example of the program’s output can be seen on Figure 13.

Figure 13 - Neuron heatmap from the Iris dataset

17

Page 18: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

The same information is presented slightly differently in neuron weights change map. The heatmap shows the change of the average of a neuron’s weight. In this graph, actual numbers have also been provided. A sample of the program output can be seen on Figure 14.

Figure 14- Weights change average of the Iris data set

Weights change during training. The artihmetic mean of the weights can be seen on the weights change chart. A sample of the program output can be seen on Figure 14.

Figure 15 - Weights change graph of the Iris dataset

Every iteration decreases the size of the neighborhood radius. This is illustrated on the Distance from BMU graph. A sample of the program’s output can be seen on Figure 16.

Figure 16 - Decreasing neighborhood radius

18

Page 19: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

6 ConclusionThe project has given an overview of the subject matter and related work done on the same topic. The primary goal of this project was to create a program that implements SOMs and allows visualizing different aspects of the training process. Self Organizing Feature Maps, a program created by  Bashir Magomedov  was used as the basis for our program. Six different graphs were added to represent different aspects of the training process. Also, some configuration options and compatibility with the WEKA file format were added. 

The completed program can be used by students and other interested parties who wish to understand the inner workings of SOMs better.

19

Page 20: Table of figuresmihkel.org/failid/Data Mining.docx · Web viewProject for MTAT.03.183 Data Mining Table of contents Table of figures3 Abstract4 1 Introduction5 2 Related Work6 3 Self-Organizing

References[1] T. Kohonen, T. Honkela, Kohonen Network, 2007 

[2] Image generated by demo program from AI-junkie.com http://www.ai-junkie.com/ann/som/som1.html Last visited 2.12.2011

[3] Image from http://neurondotnet.freehostia.com/manual/neighborhood.html Last visited 5.12.2011

[4] Image from http://neurondotnet.freehostia.com/manual/neighborhood.html Last visited 5.12.2011

[5] Tom Germano, http://davis.wpi.edu/~matt/courses/soms/applet.html Last visited 9.12.2011

[6] Christian Borgelt, http://www.borgelt.net/doc/somd/somd.html Last visited 9.12.2011

[7] George K Matsopoulos, http://www.intechopen.com/books/show/title/self-organizing-maps Last visited 13.12.2011

[8] Bashir Magomedov, http://www.codeproject.com/KB/recipes/sofm.aspx Last visited 13.12.2011

AppendixThe program is available for download at http://mihkel.org/failid/SOM.7z

The program requires .NET Framework 4.0 to run. .NET 4.0 can be downloaded from http://www.microsoft.com/download/en/details.aspx?id=17851

20