
How to obtain the values of data that fall within each cluster in Self Organizing Map algorithm
1 次查看(过去 30 天)
显示 更早的评论
clear
clc
%Sample inputs: RSRP and RSSI in dBm
RSRP = [-81.24 -73.16 -87.96 -86.31 -89.46 -78.26 -89.68 -83.83 -85.82 -90.76 -68.44 -87.41 -85.10 -80.59 -90.82 -80.70 -73.84 -81.48 -90.97 -88.60];
RSSI = [-50.44 -42.36 -57.17 -55.52 -58.67 -47.47 -58.89 -53.04 -55.03 -59.97 -37.65 -56.62 -54.30 -49.80 -60.03 -49.91 -43.05 -50.69 -60.18 -57.81];
sample_inputs = [RSRP; RSSI];
inputs = sample_inputs;
% Create a Self-Organizing Map
dimension1 = 3;
dimension2 = 3;
net = selforgmap([dimension1 dimension2]);
% Train the Network
[net,tr] = train(net,inputs);
% Test the Network
outputs = net(inputs);
% View the Network
view(net)
% Plots
figure, plotsomtop(net)
figure, plotsomhits(net,inputs)
My Question
The above scripts clusters the set of two inputs. My problem is how to determine the respective inputs that fall within each cluster.
0 个评论
回答(1 个)
Purvaja
2025-4-1
To print the points cluster wise, you can use “outputs” generated after training the SOM network.
The output of an SOM network is a matrix where each column contains activation values generated by each neuron for each input when passed through the network. Hence, by noting down the neurons which generated highest activation values for each input value we can cluster those input values accordingly, such as input values having highest activation value for same neuron will fall in same cluster.
The below code snippet demonstrates how to achieve the same:
% Determine which inputs belong to which cluster
[~, cluster_indices] = max(outputs, [], 1);
% Map each input to its respective cluster
clustered_inputs = cell(dimension1 * dimension2, 1);
for i = 1:length(cluster_indices)
cluster_number = cluster_indices(i);
clustered_inputs{cluster_number} = [clustered_inputs{cluster_number}, inputs(:,i)];
end
% Display the inputs in each cluster
for i = 1:length(clustered_inputs)
disp(['Cluster ' num2str(i) ':']);
disp(clustered_inputs{i});
end
This will display the cluster number along with the respective points belonging to that cluster as shown below:

For more details, kindly refer to the following MathWorks documentation:
Cluster with Self-Organizing Map Neural Network : https://www.mathworks.com/help/deeplearning/gs/cluster-data-with-a-self-organizing-map.html
To access the documentation for the MATLAB release you are using, please execute the following command in the MATLAB command window:
web(fullfile(docroot, 'deeplearning/gs/cluster-data-with-a-self-organizing-map.html'))
Hope this helps you!
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!