Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize intrusion clustering of GRNN Network based on Generalized Neural Network by matlab

Shulou Source: shulou.com Published: 2022-06-01 03:19:07 10月02日 Update

This article mainly introduces matlab how to achieve GRNN network intrusion clustering based on generalized neural network related knowledge, detailed and easy to understand, simple and fast operation, with certain reference value, I believe that everyone reading this matlab how to achieve GRNN network intrusion clustering based on generalized neural network articles will have some gains, let's take a look at it.

%% Empty environment files

clear

clc

%% Extract attack data

% Attack Sample Data

load netattack;

P1=netattack;

T1=P1(:,39)';

P1(:,39)=[];

% Data Size

[R1,C1]=size(P1);

csum=20; % How much training data is extracted

%% Fuzzy Clustering

data=P1;

[center,U,obj_fcn] = fcm(data,5);

for i=1:R1

[value,idx]=max(U(:,i));

a1(i)=idx;

end

%% Fuzzy Cluster Result Analysis

Confusion_Matrix_FCM=zeros(6,6);

Confusion_Matrix_FCM(1,:)=0:5;

Confusion_Matrix_FCM(:,1)=[0:5]';

for nf=1:5

for nc=1:5

Confusion_Matrix_FCM(nf+1,nc+1)=length(find(a1(T1==nf)==nc));

end

end

%% Network training sample extraction

cent1=P1(a1==1,:);cent1=mean(cent1);

cent2=P1(a1==2,:);cent2=mean(cent2);

cent3=P1(a1==3,:);cent3=mean(cent3);

cent4=P1(a1==4,:);cent4=mean(cent4);

cent5=P1(a1==5,:);cent5=mean(cent5);

% Extract norm minimum for training samples

for n=1:R1

ecent1(n)=norm(P1(n,:)-cent1);

ecent2(n)=norm(P1(n,:)-cent2);

ecent3(n)=norm(P1(n,:)-cent3);

ecent4(n)=norm(P1(n,:)-cent4);

ecent5(n)=norm(P1(n,:)-cent5);

end

for n=1:csum

[~, me1]=min(ecent1);

[~, me2]=min(ecent2);

[~, me3]=min(ecent3);

[~, me4]=min(ecent4);

[va, me5]=min(ecent5);

ecnt1(n,:)=P1(me1(1),:);ecent1(me1(1))=[];tcl(n)=1;

ecnt2(n,:)=P1(me2(1),:);ecent2(me2(1))=[];tc2(n)=2;

ecnt3(n,:)=P1(me3(1),:);ecent3(me3(1))=[];tc3(n)=3;

ecnt4(n,:)=P1(me4(1),:);ecent4(me4(1))=[];tc4(n)=4;

ecnt5(n,:)=P1(me5(1),:);ecent5(me5(1))=[];tc5(n)=5;

end

P2=[ecnt1;ecnt2;ecnt3;ecnt4;ecnt5];T2=[tcl,tc2,tc3,tc4,tc5];

k=0;

%% iterative calculation

for nit=1:10% Start iteration

%% Generalized Neural Network Clustering

net = newgrnn(P2',T2,50);

% Training Generalized Networks

a2=sim(net,P1') ;

% Forecast Results

% Output Normalized (Classified by Output)

a2(a21.5&a22.5&a23.5&a24.5)=5;

%% Network training data extracted again

cent1=P1(a2==1,:);cent1=mean(cent1);

cent2=P1(a2==2,:);cent2=mean(cent2);

cent3=P1(a2==3,:);cent3=mean(cent3);

cent4=P1(a2==4,:);cent4=mean(cent4);

cent5=P1(a2==5,:);cent5=mean(cent5);

for n=1:R1% Calculate the distance from the sample to each center

ecent1(n)=norm(P1(n,:)-cent1);

ecent2(n)=norm(P1(n,:)-cent2);

ecent3(n)=norm(P1(n,:)-cent3);

ecent4(n)=norm(P1(n,:)-cent4);

ecent5(n)=norm(P1(n,:)-cent5);

end

% Select csum samples closest to the center of each class

for n=1:csum

[~, me1]=min(ecent1);

[~, me2]=min(ecent2);

[~, me3]=min(ecent3);

[~, me4]=min(ecent4);

[va, me5]=min(ecent5);

ecnt1(n,:)=P1(me1(1),:);ecent1(me1(1))=[];tc1(n)=1;

ecnt2(n,:)=P1(me2(1),:);ecent2(me2(1))=[];tc2(n)=2;

ecnt3(n,:)=P1(me3(1),:);ecent3(me3(1))=[];tc3(n)=3;

ecnt4(n,:)=P1(me4(1),:);ecent4(me4(1))=[];tc4(n)=4;

ecnt5(n,:)=P1(me5(1),:);ecent5(me5(1))=[];tc5(n)=5;

end

p2=[ecnt1;ecnt2;ecnt3;ecnt4;ecnt5];

T2=[tc1,tc2,tc3,tc4,tc5];

% Statistical classification results

Confusion_Matrix_GRNN=zeros(6,6);

Confusion_Matrix_GRNN(1,:)=0:5;

Confusion_Matrix_GRNN(:,1)=[0:5]';

for nf=1:5

for nc=1:5

Confusion_Matrix_GRNN(nf+1,nc+1)=length(find(a2(T1==nf)==nc));

end

end

pre2=0;

for n=2:6

pre2=pre2+max(Confusion_Matrix_GRNN(n,:));

end

pre2=pre2/R1*100;

end

About "matlab how to achieve network intrusion clustering based on generalized neural network GRNN" The content of this article is introduced here, thank you for reading! I believe everyone has a certain understanding of "matlab how to achieve network intrusion clustering based on generalized neural network GRNN" knowledge. If you still want to learn more knowledge, please pay attention to the industry information channel.

Tags: Network generalized neural neural network data sample training knowledge result content article classification attack output iteration minimum value again size simple operation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi MySQL NVidia Xiaomi Huawei