SOM or Self organizing map is a unsupervised classifier. What it means is when you train the network with a matrix of features, you don’t tell which class these features belongs to as against other classifiers like KNN, SVM and ANN where train has atleast 2 arguments: Features and Labels.
First thing that you need to understand is Self Organizing Map in itself is not a classifier. When you give N number of Features, It can map them to a two dimensional feature plane. Measuring the distance between two points is always easy since last 2000 years (Curtsey Mr. Pythagoras which is later refined by Euclidian).
So suppose you have three classes A,B,C with 7 features each to represent the class. SOM can model it to X-Y plane ( a Lattice Structure) based on the lattice size you specify. It further tells you about the ‘hits’. They are nothing but the point in the new plane where each feature is appearing. But what it does not tell you is where actually each feature is sitting. It can not, because it is unsupervised.
So what is to be done?
Very Simple, make SOM behave like a Supervised Classifier.
1) Form SOM from set of features from the training vectors.
2) Search each training vectors independently in SOM and find the x,y of that point by testing each point in SOM.
3) So after step two, you know which the points where each class is appearing are. Make a group of these points per class.
4) Now take a test vector.
But your test vector has 7 features and training set now has only 2 features. How can you test? So understand this very important thing, for SOM you need to build the Map by combining train and Test vectors together. After forming the matrix, remove the last row, which is your test vector and proceed for step 1).
5) Find the location of the test vector through test process.
6) Find the closeness of test x,y points to each of positions your train classes are grouped as obtained from step 3. It is a Nearest Distance stuff from here.
Let mX is the combined features from both N training and M testing Classes. Further Consider that Features of a Class is Organized as Row. So each column represents a class.
%Implementation of Step 2.
%Implementation of Step 5