web browser http://www.ilovematlab.cn/thread-64642-1-1.html
%% 清空环境文件
clear all;
clc;
%% 提取攻击数据
%攻击样本数据
load netattack;
P1=netattack;
T1=P1(:,39)';
P1(:,39)=[];
%数据大小
[R1,C1]=size(P1);
csum=20; %提取训练数据多少
%% 模糊聚类
data=P1;
[center,U,obj_fcn] = fcm(data,5);
for i=1:R1
[value,idx]=max(U(:,i));
a1(i)=idx;
end
%% 模糊聚类结果分析
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(find(T1==nf))==nc));
end
end
%% 网络训练样本提取
cent1=P1(find(a1==1),:);cent1=mean(cent1);
cent2=P1(find(a1==2),:);cent2=mean(cent2);
cent3=P1(find(a1==3),:);cent3=mean(cent3);
cent4=P1(find(a1==4),:);cent4=mean(cent4);
cent5=P1(find(a1==5),:);cent5=mean(cent5);
%提取范数最小为训练样本
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
[va me1]=min(ecent1);
[va me2]=min(ecent2);
[va me3]=min(ecent3);
[va 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;
%% 迭代计算
for nit=1:10%开始迭代
%% 广义神经网络聚类
net = newgrnn(P2',T2,50); %训练广义网络
a2=sim(net,P1') ; %预测结果
%输出标准化(根据输出来分类)
a2(find(a2<=1.5))=1;
a2(find(a2>1.5&a2<=2.5))=2;
a2(find(a2>2.5&a2<=3.5))=3;
a2(find(a2>3.5&a2<=4.5))=4;
a2(find(a2>4.5))=5;
%% 网络训练数据再次提取
cent1=P1(find(a2==1),:);cent1=mean(cent1);
cent2=P1(find(a2==2),:);cent2=mean(cent2);
cent3=P1(find(a2==3),:);cent3=mean(cent3);
cent4=P1(find(a2==4),:);cent4=mean(cent4);
cent5=P1(find(a2==5),:);cent5=mean(cent5);
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
%选择离每类中心最近的csum个样本
for n=1:csum
[va me1]=min(ecent1);
[va me2]=min(ecent2);
[va me3]=min(ecent3);
[va 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];
%统计分类结果
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(find(T1==nf))==nc));
end
end
pre2=0;
for n=2:6;
pre2=pre2+max(Confusion_Matrix_GRNN(n,:));
end
pre2=pre2/R1*100;
end
%% 结果显示
Confusion_Matrix_FCM
Confusion_Matrix_GRNN
web browser http://www.ilovematlab.cn/thread-64642-1-1.html
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【项目资源】:包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。【项目质量】:所有源码都经过严格测试,可以直接运行。功能在确认正常工作后才上传。【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。【附加价值】:项目具有较高的学习借鉴价值,也可直接拿来修改复刻。对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。【沟通交流】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。鼓励下载和使用,并欢迎大家互相学习,共同进步。
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![py](https://img-home.csdnimg.cn/images/20210720083646.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 2 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/6ba19994c6c3461f8cf75ff80f635020_qq_34910341.jpg!1)
CyMylive.
- 粉丝: 7508
- 资源: 4万+
![benefits](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-1.c8e153b4.png)
下载权益
![privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-2.ec46750a.png)
C知道特权
![article](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-3.fc5e5fb6.png)
VIP文章
![course-privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-4.320a6894.png)
课程特权
![rights](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-icon.fe0226a8.png)
开通VIP
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)