Self-Organizing Map (SOM): R code — All you have to do is just preparing data set (very simple, easy and practical)
I release R code of Self-Organizing Map (SOM). They are very easy to use. You prepare data set, and just run the code! Then, SOM can be obtained. Very simple and easy!
You can buy each code from the URL below.
Please download the supplemental zip file (this is free) from the URL below to run the SOM code.
Procedure of SOM in the R code
To perform appropriate SOM, the R code follow the procedure below, after data set is loaded.
1. Decide the type of SOM
You select hexagon or rectangle as shape of each neuron. Default is hexagon.
2. Decide whether SOM is mapping torus or not
Mapping torus means that the right of the right edge is the left edge and the upside of the top edge is the bottom edge. So, shape of SOM is like doughnut sterically. Default is mapping torus
3. Decide map size of SOM
You decide the number of neurons in column and that in row. The number of all neurons, which means (the number of columns) × (the number of rows), should be lower than the number of samples.
4. Decide the number of iterations in training SOM
This number should be large. For example, it is 100.
5. Decide learning rate
For example, it is 0.01 or 0.03. It can be decreased gradually at each step.
6. Autoscale each variable (if necessary)
Autoscaling means centering and scaling. Mean of each variable becomes zero by subtracting mean of each variable from the variable in centering. Standard deviation of each variable becomes one by dividing standard deviation of each variable from the variable in scaling.
7. Train SOM
8. Check the point on SOM for each sample
9. Check clusters by using U-matrix
How to perform SOM
1. Buy the code and unzip the file
2. Download and unzip the supplemental zip file (this is free)
3. Place the supplemental files at the same directory or folder as that of the SOM code.
4. Prepare data set. For data format, see the article below.
5. Run the code!
Please see the article below.