[Data analysis] data classification based on matlab SOM [including Matlab source code 238]

1. Introduction

1 SOM principle analysis.
In terms of network structure, self-organizing competition network is generally a single-layer network composed of input and competition layers. The network has no hidden layer. The neurons between the input and the competition layer realize bidirectional links, and each neuron in the competition layer There is also a horizontal connection between them.
The basic idea of ​​self-organizing competitive network is that each neuron in the competition layer of the network competes for the opportunity to respond to the input pattern. In the end, only one neuron becomes the winner of the competition, and the direction of the connection weights related to the winning neuron is more favorable. The direction of competition is adjusted. The winning neuron represents the classification of the input pattern.
In addition to the competition method, there is also the victory through the suppression method, that is, the neurons in each layer of the network competition layer can inhibit the response opportunities of all other neurons to the input pattern, thereby making themselves a winner.
In addition, there is a method of inhibition, that is, each neuron only inhibits the neurons that are close to it, and does not inhibit the neurons that are far away from it. Therefore, the self-organizing and self-adapting learning ability of self-organizing competitive network further broadens the application of neural network in pattern recognition and classification.
In 1981, Professor T.Kohonen of Helsink University in Finland proposed a self-organizing feature mapping network, referred to as SOM network, or Kohonen network. In the biological nervous system, there is a phenomenon of "side inhibition", that is, after a nerve cell is excited, its branches will inhibit other surrounding nerve cells. Due to the effect of side inhibition, the final result of the competition between cells is: the inhibitory effect produced by the nerve cell with the strongest excitatory effect defeats the inhibitory effect of all other surrounding cells and "wins", and other nerve cells around it Then all "lost".
Kohonen believes that when a neural network accepts external input patterns, it will be divided into different corresponding areas, each area has different response characteristics to the input pattern, and this process is completed automatically. The self-organizing competitive artificial neural network is formed based on the above-mentioned biological system structure and phenomenon. It is a kind of neural network with self-organizing function in a way of learning without a tutor. The network automatically classifies input patterns through its own training.
2 SOM topology analysis
Self-organizing Feature Maps (Self-organizing Feature Maps) is abbreviated as SOFM or SOM, and it is also a network without tutor learning, which is mainly used to classify input vectors. Different from the self-organizing competitive network, it not only identifies the area adjacent to the input area, but also studies the distribution characteristics and topological characteristics of the input vector.
The SOM network simulates the function of self-organizing feature mapping of the brain and nervous system. It is a competitive network and can perform self-organized learning without a tutor.
The results of cranial neurology research show that the common feature of the information interaction between neurons is that the two nearest neighbor neurons stimulate each other, the more distant neurons inhibit each other, and the farther neuron has a weaker stimulation effect.
Insert picture description here
Since the SOM algorithm is a clustering method without a tutor, it can map any dimensional input pattern into a one-dimensional or two-dimensional discrete graph in the output layer, and keep its topological structure unchanged. The self-organizing learning of the input mode expresses the classification results in the competition layer. In addition, the network can make the spatial distribution density of connection weights and the probability distribution of the input mode converge through repeated learning of the input mode, that is, the link weight vector distribution Can reflect the statistical characteristics of the input mode.
Like the self-organizing competitive network, the SOM network can be used to identify the winning neuron. The difference is that the self-organizing competitive network only modifies the winning neuron, while the SOM network, according to the Kohonen learning rule, must also modify the area near the winning neuron Ni(d ) All neurons.
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
3 SOM's cancer sample classification prediction
SOM is a type of neural network model that uses teacher-free learning. It does not need to expect output, but only learns based on data samples and adjusts its own weight to achieve the purpose of learning. Most of the learning rules of self-organizing neural networks adopt competitive learning rules.
The basic idea of ​​the competitive neural network is that each neuron in the competition layer of the network obtains the opportunity to respond to the input pattern through competition. In the end, only one neuron becomes the winner, and the connection weights related to the winning neuron are directed toward this. More favorable direction adjustment.
Self-organizing map neural network uses: pattern classification and pattern recognition. The specific network layer structure diagram is shown in Figure 29-8.
Insert picture description here

Second, the source code

clc % 清屏
clear all; % 删除workplace变量
close all; % 关掉显示图形窗口
format short
% Initial
%% gridtop()网络拓扑结构
pos = gridtop(2,3)
figure,plotsom(pos)
grid on
%% Hextop()函数生成一个六角形形式的拓扑结构
pos = hextop(2,3)
figure,plotsom(pos)
grid on
%% 8*10 神经元拓扑结构来看看六角形神经元拓扑图像
pos = hextop(8,10)
figure,plotsom(pos)
grid on
%% randtop()函数生成的是N维随机形式分布的神经元拓扑结构
pos = randtop(2,3)
figure,plotsom(pos)
grid on
%% 网络建立和训练
% newsom建立SOM网络。minmax(P)取输入的最大最小值。竞争层为6*6=36个神经元
net=newsom(minmax(P),[6 6]);
plotsom(net.layers{
    
    1}.positions)
% 5次训练的步数
a=[10 30 50 100 200 500 1000];
% 随机初始化一个1*10向量。
yc=rands(7,8);
%% 进行训练
% 训练次数为10
net.trainparam.epochs=a(1);
% 训练网络和查看分类
net=train(net,P);
y=sim(net,P);
yc(1,:)=vec2ind(y);
plotsom(net.IW{
    
    1,1},net.layers{
    
    1}.distances)

% 训练次数为30
net.trainparam.epochs=a(2);
% 训练网络和查看分类
net=train(net,P);
y=sim(net,P);
yc(2,:)=vec2ind(y);
plotsom(net.IW{
    
    1,1},net.layers{
    
    1}.distances)

% 训练次数为50
net.trainparam.epochs=a(3);
% 训练网络和查看分类
net=train(net,P);
y=sim(net,P);
yc(3,:)=vec2ind(y);
plotsom(net.IW{
    
    1,1},net.layers{
    
    1}.distances)

Three, running results

Insert picture description here
Insert picture description here
Insert picture description here

Four, remarks

Complete code or writing add QQ1564658423 past review
>>>>>>
[Data analysis] based on matlab time-varying parameter stochastic volatility vector autoregressive model (TVP-VAR) [including Matlab source code 099 period]
[data analysis] based on matlab Time-varying parameter stochastic volatility vector of autoregressive model (TVP-VAR) [including Matlab source code 153]
[Fault detection problem] Matlab immune algorithm-based fault detection problem [including Matlab source code 196]
[Data clustering] based on Clustering design of matlab particle swarm algorithm [including Matlab source code 199]
[Data clustering] based on matlab simulated annealing algorithm clustering design [including Matlab source code 200]
[Data clustering] based on matlab genetic algorithm clustering design [including Matlab source code 201 period]
[Data clustering] based on matlab ant colony algorithm clustering design [including Matlab source code 202 period]
[Data analysis] based on matlab GUI interface for different GUI data import [including Matlab source code 211 period]
[Data analysis] based on Matlab GUI interface score management system [including Matlab source code 212]
[Data analysis] based on matlab GUI interface perpetual calendar [including Matlab source code 213]
[Data analysis] based on matlab Bayesian judgment of airport flight delay factor analysis [including Matlab Source code 230]

Guess you like

Origin blog.csdn.net/TIQCmatlab/article/details/113725083