clc;
clear all;
close all;
warning off;
addpath 'func\';
rng('default');
load DATA\breast.mat
%训练比例
L = 0.6;
P = breast(:,1:9);
T = round(breast(:,end)/2);
MTKL= 100;
I1 = find(T==1);
I2 = find(T==2);
idx1= [I1(1:floor(L*length(I1)));I2(1:floor(L*length(I2)))];
idx2= [I1(1+floor(L*length(I1)):end);I2(1+floor(L*length(I2)):end)];
for j = 1:MTKL
j
rng(j);
Ptrain = P(idx1,:);
Ptest = P(idx2,:);
Ttrain = T(idx1);
Ttest = T(idx2);
%数据输入
net2 = newff(Ptrain',Ttrain',4,{'tansig', 'purelin'}, 'traingd'); % 隐含层有5个神经元
net2.trainParam.goal = 1e-5;
net2.trainParam.epochs = 1000;
net2.trainParam.lr = 0.0025;
net2.trainParam.showWindow = 0;
net2 = train(net2,Ptrain',Ttrain');
y = [round(sim(net2,Ptest'))]';
[A,~]= confusionmat(Ttest,y);
%计算-1类的评价值
c1_precise(j) = A(1,1)/(A(1,1) + A(2,1));
c1_recall(j) = A(1,1)/(A(1,1) + A(1,2));
c1_F1(j) = 2 * c1_precise(j) * c1_recall(j)/(c1_precise(j) + c1_recall(j));
%计算1类的评价值
c2_precise(j) = A(2,2)/(A(1,2) + A(2,2));
c2_recall(j) = A(2,2)/(A(2,1) + A(2,2));
c2_F1(j) = 2 * c2_precise(j) * c2_recall(j)/(c2_precise(j) + c2_recall(j));
end
idx=[];
for i =1:MTKL
if isnan(c1_precise(i))==1 | isnan(c1_recall(i))==1 | isnan(c1_F1(i))==1 | isnan(c2_precise(i))==1 | isnan(c2_recall(i))==1 | isnan(c2_F1(i))==1
idx=[idx,i];
end
end
c1_precise(idx)=[];
c1_recall(idx)=[];
c1_F1(idx)=[];
c2_precise(idx)=[];
c2_recall(idx)=[];
c2_F1(idx)=[];
R = [mean(c1_precise),mean(c1_recall),mean(c1_F1),mean(c2_precise),mean(c2_recall),mean(c2_F1)]
figure;
bar([mean(c1_precise),mean(c2_precise)]);title('识别率');
figure;
bar([mean(c1_recall),mean(c2_recall)]);title('召回率');
figure;
bar([mean(c1_F1),mean(c2_F1)]);title('F1');
save R1.mat c1_precise c1_recall c1_F1 c2_precise c2_recall c2_F1
fpga和matlab
- 粉丝: 17w+
- 资源: 2635
最新资源
- COMSOL物理模型:微波波段金属超表面吸收器
- 机器学习(预测模型):于信用卡审批预测的机器学习数据集
- 锂电池均衡 主动均衡 simulink仿真 耦合电感类 耦合电感四节电池 耦合电感加开关电容的六节电池
- bupt2024大一上字符串练习括号匹配
- YOLOv8-deepsort 实现智能车辆目标检测+车辆跟踪+车辆计数
- PEM电解槽三维两相流模拟,包括电化学,两相流传质,析氢析氧,化学反应热等多物理场耦合,软件comsol,可分析多孔介质传质,析氢析氧过程对电解槽电流密度分布,氢气体积分数,氧气体积分数,液态水体积分
- 高性能汽车级FM/AM/LW/SW/RDS收音机接收芯片QX201/201C特性及应用
- 999-电磁小车.zip
- 机器学习(预测模型):600个库存单位(SKUs)的每日店铺销售和收入信息数据集
- 基于javaweb的人事管理系统
- 固体氧化物燃料电池SOFC模型,COMSOL电池仿真计算
- matlab实现光纤激光器在不同长度与掺杂浓度下的数值模拟研究-光纤激光器-数值模拟-光纤仿真-matlab
- 面试求职知识结构图(mysql篇)
- matlab实现光纤激光器双端抽运模型增益光纤内部的功率分布-光纤激光器-双端抽运模型-增益光纤-功率分布-matlab
- comsol模拟水力压裂,固体力学+达西定理
- 全波段FM/AM汽车级接收器QX300的高性能接收技术与应用
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
前往页