Detailed summary of machine learning classification methods

There are tutors to learn the classification of neural networks

Generalized Regression Neural Network (GRNN)

    1.GRNN结构
    GRNN最早是由Specht提出的,是RBF神经网络的一个分支,是一种基于非线性回归理
论的前馈式神经网络模型。
GRNN的结构如图所示,一般由输人层、隐含层和输出层组成。输人层仅将样本
变量送入隐含层,并不参与真正的运算。隐含层的神经元个数等于训练集样本数,该层的权值
函数为欧式距离函数(用|dist表示),其作用为计算网络输人与第一层的权值IW,之间的距
离,b为隐含层的阈值。隐含层的传递函数为径向基函数,通常采用高斯函数作为网络的传
递函数。网络的第三层为线性输出层,其权函数为规范化点积权函数(用nprod表示),计算网
络的向量为n',它的每个元素就是向量a'和权值矩阵LW每行元素的点积再除以向量a'
的各元素之和得到的,并将结果n提供给线性传递函数a=purelin(n'),计算网络输出。

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

Probabilistic Neural Network (PNN)

1.PNN结构
PNN是一种前馈型神经网络,由Specht在1989年提出,他采用Parzen 提出的由高斯函
数为基函数来形成联合概率密度分布的估计方法和贝叶斯优化规则,构造了一种概率密度分
类估计和并行处理的神经网络。因此,PNN既具有一般神经网络所具有的特点,又具有很好
的泛化能力及快速学习能力。
PNN的结构如图所示,与GRNN类似,由输人层、隐含层及输出层组成。与
GRNN不同的是,PNN的输出层采用竞争输出代替线性输出,各神经元只依据Parzen方法来
求和估计各类的概率,从而竞争输入模式的响应机会,最后仅有一个神经元竞争获胜,这样获
胜神经元即表示对输人模式的分类。
在数学上,PNN的结构合理性可由Cover定理证明,即对于一个模式问题,在高维数据空
间中可能解决在低维空间不易解决的问题。这就是PNN隐含层神经元较多的原因,即隐含
层空间维数较高。隐含层空间的维数和网络性能有着直接的关系,维数越高,网络的逼近精度
就越高,但带来的负面后果是网络复杂度也随之提高。

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

Title and code

The classification and identification of plants is an important basic work in botany research and agricultural and forestry production and management. It is of great significance for distinguishing plant species
, exploring the genetic relationship between plants, and clarifying the evolutionary laws of plant systems. At present, the commonly used
method for identifying plant species is to use the classification key for identification, but this method takes a lot of time, and the establishment of the classification key is a time-consuming and
laborious work, requiring a lot of financial and material resources.
The leaf is an important part of the plant, and the outer contour of the leaf is its main morphological feature. On the
basis of extracting leaf morphological features , computer-assisted classification and recognition have become the current main research direction, and it is also the hotspot and
focus of research .
150 is now set to collect different types of iris (Setosa, Versicolour and Virginica) four kinds of attributes: Duration SIM
relationship ﹑ Xiong of sheet width, and length of petal petal width, number of samples with different kinds of attributes as in FIG. 26-3 (Among them, the sample
number 150 is Setosa, 51 100 is Versicolour, and 101~150 are Virginica). It can be roughly seen from the figure that
there is a good linear relationship between petal length, petal width and iris flower type, while there is a non-linear relationship between Xiong piece length, shroud width and iris flower
type.
Insert picture description here
Now requirements:
(1) Use GRNN and PNN to establish iris flower species recognition models, and evaluate the performance of the models.
(2) Use GRNN and PNN to establish the recognition model between each attribute and attribute combination and the iris flower species, and
compare with the performance and computing time of the model built in (1), so as to explore each attribute and attribute combination and iris flower The
degree of relevance of the category .

% 有导师学习神经网络的分类 -- 鸢尾花种类识别
clear
clc
% 产生训练集/测试集
load iris_data.mat
Ptrain = [];
ttrain = [];
Ptest = [];
ttest = [];
for i = 1:3
    tempinput = features((i-1)*50+1:i*50,:);
    tempoutput = classes((i-1)*50+1:i*50,:);
    n = randperm(50);
    Ptrain = [Ptrain tempinput(n(1:40),:)'];
    ttrain = [ttrain tempoutput(n(1:40),:)'];
    Ptest = [Ptest tempinput(n(41:50),:)'];
    ttest =[ttest tempoutput(n(41:50),:)'];
end
% 建立模型
resultgrnn = [];
resultpnn = [];
timegrnn = [];
timepnn = [];
for i = 1:4
    for j = i:4
        ptrain = Ptrain(i:j,:);
        ptest = Ptest(i:j,:);
        t = cputime;
        netgrnn = newgrnn(ptrain,ttrain);
        tsimgrnn = sim(netgrnn,ptest);
        Tsimgrnn = round(tsimgrnn);
        t = cputime - t;
        timegrnn = [timegrnn t];
        resultgrnn = [resultgrnn Tsimgrnn'];
        t = cputime;
        tctrain = ind2vec(ttrain);
        netpnn = newpnn(ptrain,tctrain);
        tctest = ind2vec(ttest);
        tsimpnn = sim(netpnn,ptest);
        Tsimpnn = vec2ind(tsimpnn);
        t = cputime - t;
        timepnn = [timepnn t];
        resultpnn = [resultpnn Tsimpnn'];
    end
end
% 性能评价
accuracygrnn = [];
accuracypnn = [];
time = [];
for i = 1:10
    accuracy1 = length(find(resultgrnn(:,i)==ttest'))/length(ttest);
    accuracy2 = length(find(resultpnn(:,i)==ttest'))/length(ttest);
    accuracygrnn = [accuracygrnn accuracy1];
    accuracypnn = [accuracypnn accuracy2];
end
result = [ttest' resultgrnn resultpnn];
accuracy = [accuracygrnn;accuracypnn];
time = [timegrnn;timepnn];
% 画图
figure(1)
plot(1:30,ttest,'bo',1:30,resultgrnn(:,4),'r-*',1:30,resultpnn(:,4),'k:^')
grid on
xlabel('测试集样本编号')
ylabel('测试集样本类别')
string = {
    
    '测试集预测结果对比(GRNN vs PNN)';['正确率',num2str(accuracygrnn(4)*100),'%(GRNN) vs',num2str(accuracypnn(4)*100),'%(PNN)']};
title(string)
legend('真实值','GRNN预测值','PNN预测值')
figure(2)
plot(1:10,accuracy(1,:),'r-*',1:10,accuracy(2,:),'b:o')
grid on 
xlabel('模型编号')
ylabel('测试集正确率')
title('10个模型的测试集正确率对比(GRNN vs PNN)')
legend('GRNN','PNN')
figure(3)
plot(1:10,time(1,:),'r-*',1:10,time(2,:),'b:o')
grid on
xlabel('模型编号')
ylabel('运行时间(s)')
title('10个模型的运行时间对比(GRNN vs PNN)')
legend('GRNN','PNN')

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

Unsupervised learning neural network classification

Competitive neural network

1. 竞争神经网络结构
竞争神经网络是一种典型的、应用非常广泛的无导师学习神经网络,其结构如图所
示。竞争神经网络一般由输人层和竞争层组成。与RBF等神经网络类似,输入层仅实现输人
模式的传递,并不参与实际的运算。竞争层的各个神经元以相互竞争的形式来赢得对输人模
式的响应,最终只有一个神经元赢得胜利,并使与该获胜神经元相关的各连接权值和阈值向着
更有利于其竞争的方向发展,而其他神经元对应的权值和阈值保持不变。

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

SOFM neural network structure

Insert picture description here

Problem and code

In recent years, domestic coal mine accidents have occurred from time to time, seriously endangering people's lives and property safety. Among them,
accidents caused by water inrush from coal mines cannot be ignored. Therefore, many experts and scholars have devoted themselves to studying the prevention of water
inrush accidents in mines , and the identification of water inrush water sources is of great significance for predicting the occurrence of water inrush accidents in mines.
Relevant studies have shown that the hydrochemical method can be used to identify the source of water inrush in a mine. The basic basis is
that it is stored in different aquifers due to the influence of many factors such as the deposition period of the aquifer , stratum lithology, construction and geochemical environment. The main
chemical composition of the groundwater is different. In order to accurately determine the source of water inrush, a variety of factors need to be integrated, and the "7 major
ions" dissolved oxygen and nitrate ions are more commonly used.
At present, there are many methods to identify the source of water inrush, such as fuzzy comprehensive evaluation, fuzzy cluster analysis, gray correlation method, etc.
However, these methods must presume the model or subjectively specify some parameters, which makes the evaluation result highly subjective. .
39 water source samples have been collected from a mine, which come from 4 main aquifers: limestone and Ordovician aquifers, eight-ash
aquifers, roof sandstone aquifers, and Quaternary aquifers (sand gravels are composed of limestone Mainly). Taking the content of
Nat, K+, Ca2+, Mg'+, Cl-, SO' and HCO, 7 kinds of ions in each water source sample as the discriminating factor, try to use competitive neural
network and SOFM neural network to establish discriminant models respectively, and The performance of the model is comprehensively evaluated.

% 无导师学习神经网络分类--矿井突水水源判别
clear
clc
% 产生训练集/测试集
load water_data.mat
attributes = mapminmax(attributes);
ptrain = attributes(:,1:35);
ttrain =classes(:,1:35);
ptest = attributes(:,36:end);
ttest = classes(:,36:end);
% 创建/训练竞争神经网络及仿真测试
net = competlayer(4,0.01,0.01);
net.trainParam.epochs = 500;
net = train(net,ptrain);
tsimcompet1 = net(ptrain);
Tsimcompet1 = vec2ind(tsimcompet1);
tsimcompet2 = net(ptest);
Tsimcompet2 = vec2ind(tsimcompet2);
% 创建SOFM神经网络仿真测试
net = selforgmap([4 4]);
net.trainParam.epochs = 200;
net = train(net,ptrain);
tsimsofm1 = net(ptrain);
Tsimsofm1 = vec2ind(tsimsofm1);
tsimsofm2 = net(ptest);
Tsimsofm2 = vec2ind(tsimsofm2);
% 性能评价
resultcompet1 = [ttrain' Tsimcompet1'];
resultcompet2 = [ttest' Tsimcompet2'];
resultsofm1 = [ttrain' Tsimsofm1'];
resultsofm2 = [ttest' Tsimsofm2'];

The following is the result graph:
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/wlfyok/article/details/108409710