zl程序教程

您现在的位置是:首页 >  后端

当前栏目

BP神经网络对水质问题进行预测(Matlab代码实现)

MATLAB神经网络代码 实现 进行 预测 bp 问题
2023-09-14 09:05:21 时间

💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

📚2 运行结果

🎉3 参考文献

🌈4 Matlab代码实现


💥1 概述

在大数据、人工智能的背景下,神经网络算法被广泛的应用和普及,风险预测问题成为人们关注的热点,BP神经网络算法是用于解决预测问题效果最好的算法之一,但传统的BP神经网络算法在隐含层权值选择过程具有一定的局限性,会影响算法预测的效率和精度。针对这种情况,提出了改进的BP神经网络算法,利用遗传算法和BP神经网络算法相结合,提升算法的预测效率和预测精度。首先,分析传统BP神经网络算法流程及不足;其次,利用遗传算法优化BP神经网络算法;最后,提出改进的BP神经网络算法执行流程,并以食品价格数据进行对比分析。通过实验分析结果可知,相对于传统的BP神经网络算法,该方法在预测过程中可以提高预测效率、提升预测精度。本文章采用BP算法并训练使用的数据集404个水质数据对水质问题进行预测。

📚2 运行结果

 部分代码:

clc 
clear all 

load out2.mat
load train.mat
outrec = outrec';
ml = [2.35500000000000,0.110000000000000,6.50000000000000,323.500000000000];
mm = [10.9945239746905,69.0063006300631,-6.66869763899466,-0.319387271030040];
for j = 1:4
    for i = 1:404
        outrec(i,j) = outrec(i,j)*ml(j)+mm(j);

    end
end

for j = 1:4
    for i = 1:404
        traind_s(i,j) = traind_s(i,j)*ml(j)+mm(j);

    end
end


xunlian = 250;
yuce = 152;

a = 1:xunlian;
b = xunlian+1:xunlian+yuce;

figure(1)
%% 拟合曲线

title('fitted');

zzl = 1;
subplot(2,2,zzl);
plot(a,traind_s(1:xunlian,zzl),'b');
hold on 
plot(a+10,outrec(1:xunlian,zzl),'r');
hold off 
xlabel('time');
ylabel('temperature');
legend('measured value','fitted value');

        
zzl =2;
subplot(2,2,zzl);
plot(a,traind_s(1:xunlian,zzl),'b');
hold on 
plot(a+10,outrec(1:xunlian,zzl),'r');
hold off 
xlabel('time');
ylabel('pH');
legend('measured value','fitted value');

zzl = 3;
subplot(2,2,zzl);
plot(a,traind_s(1:xunlian,zzl),'b');
hold on 
plot(a+10,outrec(1:xunlian,zzl),'r');
hold off 
xlabel('time');
ylabel('Do');
legend('measured value','fitted value');

zzl = 4;
subplot(2,2,zzl);
plot(a,traind_s(1:xunlian,zzl),'b');
hold on 
plot(a+10,outrec(1:xunlian,zzl),'r');
hold off 
xlabel('time');
ylabel('ORP');
legend('measured value','fitted value');

%% 预测曲线
figure(2)

zzl = 1;
subplot(2,2,zzl);

plot(b,traind_s(xunlian+1:xunlian+yuce,zzl),'b');
hold on 
plot(b+10,outrec(xunlian+1:xunlian+yuce,zzl),'r');
hold off 

xlabel('time');
ylabel('temperature');
legend('measured value','predicted value');

zzl = 2;
subplot(2,2,zzl);
plot(b,traind_s(xunlian+1:xunlian+yuce,zzl),'b');
hold on 
plot(b+10,outrec(xunlian+1:xunlian+yuce,zzl),'r');
hold off 
xlabel('time');
ylabel('pH');
legend('measured value','predicted value');

zzl = 3;
subplot(2,2,zzl);
plot(b,traind_s(xunlian+1:xunlian+yuce,zzl),'b');
hold on 
plot(b+10,outrec(xunlian+1:xunlian+yuce,zzl),'r');
hold off 
xlabel('time');
ylabel('DO');
legend('measured value','predicted value');

zzl = 4;
subplot(2,2,zzl);
plot(b,traind_s(xunlian+1:xunlian+yuce,zzl),'b');
hold on 
plot(b+10,outrec(xunlian+1:xunlian+yuce,zzl),'r');
hold off 
xlabel('time');
ylabel('ORP');
legend('measured value','predicted value');

🎉3 参考文献

部分理论来源于网络,如有侵权请联系删除。

[1]刘红梅,徐英岚,张博,李荣.基于最小二乘支持向量回归的水质预测[J].计算机与现代化,2019(09):31-34.

[2]邬希可.改进的神经网络算法在预测方法中研究与应用[J].计算机与数字工程,2022,50(10):2276-2279+2344.

🌈4 Matlab代码实现