Starting from:

$20

INT301- Week 13: Self-Organizing Map Solved

Example: 

Clustering Problem using a Self-Organizing Map (demo.m)

close all, clear all, clc, format compact  load simplecluster_dataset;

% a 2x1000 matrix of 1000 two-element vectors. x = simpleclusterInputs;  % plot clusters  figure, plot(x(1,:),x(2,:),'g.'); hold on

grid on

% Create a Self-Organizing Map  dim1 = 10;  dim2 = 10;

net = selforgmap([dim1 dim2]);  % Train the Network

[net,tr] = train(net,x);

 

% View the Network  view(net)  % Plots  figure, plotsomtop(net)  figure, plotsomnc(net) figure, plotsomnd(net)  figure, plotsomplanes(net)  figure, plotsomhits(net,x)

figure, plotsompos(net,x)

 

Exercise: 

Define 4 clusters of input data with the following piece of code, and plot input data using your own codes;
 

% number of samples of each cluster

K = 200;  % offset of classes  q = 1.1;

% define 4 clusters of input data

P = [rand(1,K)-q rand(1,K)+q rand(1,K)+q rand(1,K)-q; rand(1,K)+q rand(1,K)+q rand(1,K)-q rand(1,K)-q];

 

%% Your own codes

Create and train 2D-SOM with the following parameters using your own codes, and plot the 2D-SOM results with the following functions (you can also change the parameters accordingly).
 

% SOM parameters

dimensions = [10 10];

%% Your own codes

% plot input data and SOM weight positions  figure, plotsompos(net, P); grid on  % plot SOM neighbor distances  figure, plotsomnd(net)

% plot for each SOM neuron the number of input vectors that it classifies  figure, plotsomhits(net,P)

More products