# How to train data using SOM and map the resukts on data

3 views (last 30 days)
Ass on 12 Apr 2019
Answered: Ass on 15 Apr 2019
Pleases help me. I am stuck in how to train data using SOM and map the results on data. I am using the data file, having dimension 100 by 30. First, I want to apply som to train it and them classify the classes.Please help me to solve this problem. Its very important and urgent also.

Show 1 older comment
Ass on 12 Apr 2019
Yes, I am trying to solve it. But still not getting solution. How to map the classified classes which I have got after application of SOM on real data using som_colorcode.
KSSV on 12 Apr 2019
What approach you have used? gui or code? what? Show us code.
Ass on 12 Apr 2019
Using Somtoolbox. The data has been classified into 4 classes. But I dont know how to map these classes using som_colorcode on data. So that I will get the classes depth wise. If you have any idea please help me in this

KSSV on 12 Apr 2019
X = rands(2,1000); % some random input
plot(X(1,:),X(2,:),'+r')
net = selforgmap([2 2]); % divide into four groups
net = configure(net,X);
plotsompos(net)
net.trainParam.epochs = 1;
net = train(net,X);
plotsompos(net)
% Groups
Y = vec2ind(net(X)) ;
scatter(X(1,:),X(2,:),30,Y,'filled')
% Testing
x = [0.5;0.3];
y = vec2ind(net(x)) % the give input belongs to this group

KSSV on 15 Apr 2019
X = num' ;
dimensions = [1 5];
coverSteps = 100;
initNeighbor = 1;
topologyFcn = 'gridtop';
% define net
net = selforgmap(dimensions,coverSteps,initNeighbor,topologyFcn,distanceFcn);
net = configure(net,X);
plotsompos(net)
net.trainParam.epochs = 100;
net = train(net,X);
plotsompos(net)
% Groups
Y = vec2ind(net(X)) ;
Why train for 1 epoch only? I would think you'd need a few hundred, especially with coverSteps explicitly set at 100
KSSV on 15 Apr 2019
Yes.....a typo error.......edited now....

Ass on 15 Apr 2019
It is not working properly. For I have simply calculated best matching unit after training which gives proper classification. And epoch I have used 200