[dw,ls] = (W,P,Z,N,A,T, E,gW,gA,D,LP,LS)
其参数意义与中的参数意义相同,只是权值调整的方法不同,此处不再赘述 。
4. 实现
利用神经网络工具箱提供的函数可以方便地在环境下实现上述步骤 。
%% LVQ神经网络的分类——乳腺肿瘤诊断%% 清空环境变量clear allclcwarning off%% 导入数据load data.mata = randperm(569);Train = data(a(1:500),:);Test = data(a(501:end),:);% 训练数据P_train = Train(:,3:end)';Tc_train = Train(:,2)';T_train = ind2vec(Tc_train);% 测试数据P_test = Test(:,3:end)';Tc_test = Test(:,2)';%% 创建网络count_B = length(find(Tc_train == 1));count_M = length(find(Tc_train == 2));rate_B = count_B/500;rate_M = count_M/500;net = newlvq(minmax(P_train),20,[rate_B rate_M],0.01,'learnlv1');% 设置网络参数net.trainParam.epochs = 1000;net.trainParam.show = 10;net.trainParam.lr = 0.1;net.trainParam.goal = 0.1;%% 训练网络net = train(net,P_train,T_train);%% 仿真测试T_sim = sim(net,P_test);Tc_sim = vec2ind(T_sim);result = [Tc_sim;Tc_test]%% 结果显示total_B = length(find(data(:,2) == 1));total_M = length(find(data(:,2) == 2));number_B = length(find(Tc_test == 1));number_M = length(find(Tc_test == 2));number_B_sim = length(find(Tc_sim == 1 & Tc_test == 1));number_M_sim = length(find(Tc_sim == 2 &Tc_test == 2));disp(['病例总数:' num2str(569)...'良性:' num2str(total_B)...'恶性:' num2str(total_M)]);disp(['训练集病例总数:' num2str(500)...'良性:' num2str(count_B)...'恶性:' num2str(count_M)]);disp(['测试集病例总数:' num2str(69)...'良性:' num2str(number_B)...'恶性:' num2str(number_M)]);disp(['良性乳腺肿瘤确诊:' num2str(number_B_sim)...'误诊:' num2str(number_B - number_B_sim)...'确诊率p1=' num2str(number_B_sim/number_B*100) '%']);disp(['恶性乳腺肿瘤确诊:' num2str(number_M_sim)...'误诊:' num2str(number_M - number_M_sim)...'确诊率p2=' num2str(number_M_sim/number_M*100) '%']);
某次运行神经网络训练测试的结果如下:
病例总数:569良性:357恶性 :212训练集病例总数:500良性:312恶性 :188测试集病例总数:69良性:45恶性:24良性乳腺肿瘤确诊:43误诊:2确诊率 p1= 95.5556%恶性乳腺肿瘤确诊:20误诊:4确诊率 p2= 83.3333%
从上述结果可以看出,在69组测试集数据中,有6组数据误诊断(2组将良性乳腺肿瘤误诊为恶性乳腺肿瘤,4组将恶性乳腺肿瘤误诊为良性乳腺肿瘤),平均诊断正确率达91. 3%(63/69) 。实验结果表明,将LVQ神经网络应用于模式识别是可行的 。
5.案例拓展
本小节将对比上述 LVQ神经网络经网络两 种模 型的效果,BP神经网络模型的程序如下:
%% BP神经网络的分类——乳腺肿瘤诊断%% 创建网络net = newff(minmax(P_train),[50 1],{'tansig','purelin'},'trainlm');%% 设置网络参数net.trainParam.epochs = 1000;net.trainParam.show = 10;net.trainParam.lr = 0.1;net.trainParam.goal = 0.1;%% 训练网络net = train(net,P_train,Tc_train);%% 仿真测试T_sim = sim(net,P_test);for i = 1:length(T_sim)if T_sim(i) <= 1.5T_sim(i) = 1;elseT_sim(i) = 2;endendresult = [T_sim;Tc_test]number_B = length(find(Tc_test == 1));number_M = length(find(Tc_test == 2));number_B_sim = length(find(T_sim == 1 & Tc_test == 1));number_M_sim = length(find(T_sim == 2 &Tc_test == 2));disp(['病例总数:' num2str(569)...'良性:' num2str(total_B)...'恶性:' num2str(total_M)]);disp(['训练集病例总数:' num2str(500)...'良性:' num2str(count_B)...'恶性:' num2str(count_M)]);disp(['测试集病例总数:' num2str(69)...'良性:' num2str(number_B)...'恶性:' num2str(number_M)]);disp(['良性乳腺肿瘤确诊:' num2str(number_B_sim)...'误诊:' num2str(number_B - number_B_sim)...'确诊率p1=' num2str(number_B_sim/number_B*100) '%']);disp(['恶性乳腺肿瘤确诊:' num2str(number_M_sim)...'误诊:' num2str(number_M - number_M_sim)...'确诊率p2=' num2str(number_M_sim/number_M*100) '%']);
- 毕业设计之—基于Spatial Dropout
- 2.1、基于光源和噪声的拼接图像篡改检测方法
- 用ChatGPT写神经网络:一字不改,结果竟然很好用
- 【深度学习·实践篇】CodeT5模型学习与基于CodeT5进行新的模型训练
- 图154
- 基于Kubernetes环境的高扩展机器学习部署利器——KServe
- 用神经网络的分类过程理解夸克与反夸克渐近自由的强相互作用过程
- 基于ChatGPT聊天的零样本信息提取7.25
- chatgpt赋能Python
- 蒙特卡洛