hello all, I want to ask wht is wrong with this below SOM code?
이전 댓글 표시
I want to genrate SOM map and label it with text on it to define the clusters, for lable i defined 25, 50 , 75 and 100. when i run it it genrate the map , however, it doesnot label it with the values i define, please check the below code. thanks i will appreciate the answers.
load S_data.txt
% Separate the input features (voltage and current) and the target (fault types)
x = S_data(:, 1:6)';
y = S_data(:, 7)';
% Create class labels
t = zeros(size(y));
t(y == 25) = 25; % Set class 1 as 1
t(y == 50) = 50; % Set class 2 as 2
t(y == 75) = 75; % Set class 3 as 3
t(y == 100) = 100; % Set class 3 as 3
% Train the SOM
gridSize = [10, 10]; % Adjust the grid size as desired
epochs = 100;
learningRate = 1;
som = selforgmap(gridSize, epochs, learningRate);
som = train(som, x);
% Map the data points to the SOM grid
mapped = som(x);
% Plot the SOM map with labeled data points
figure;
imagesc(som.IW{1,1}');
colormap('jet');
colorbar;
hold on;
for i = 1:numel(t)
scatter(mapped(2,i), mapped(1,i), 20, t(i), 'filled', 'MarkerEdgeColor', 'k');
end
% Plot cluster centers
cluster_centers = som.IW{1,1}';
for i = 1:numel(t)
cluster_id = t(i);
[r, c] = find(cluster_centers == cluster_id);
scatter(c, r, 50, 'k', 'filled', 'Marker', 's', 'MarkerEdgeColor', 'k', 'LineWidth', 2);
end
hold off;
title('SOM Mapping of Transmission Line Dataset');
xlabel('Neuron X-coordinate');
ylabel('Neuron Y-coordinate');
% Display the plot
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Orange에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!