clc%清除命令窗口变量
clear%清除工作空间变量
close all%关闭FIGURE图像
rng('default')
rng(2)
load maydata.mat
n= randperm(length(num));
input_train=num(n,1:3)';%训练数据的输入数据
output_train=num(n,4:6)';%训练数据的输出数据4
input_test=num((1:end),1:3)';%测试数据的输入数据
output_test=num((1:end),4:6)'; %测试数据的输出数据
%选连样本输入输出数据归一化
[inputn,inputps]=mapminmax(input_train,-1,1);%训练数据的输入数据的归一化
[outputn,outputps]=mapminmax(output_train,-1,1);%训练数据的输出数据的归一化de
inputn_test=mapminmax('apply',input_test,inputps);
outputn_test=mapminmax('apply',output_test,outputps);
%% BP网络训练
% %初始化网络结构
%net=newff(inputn,outputn,[135,5],{'logsig','tansig'},'trainlm');
% net=newff((inputn),outputn,[230,3],{'logsig','tansig'},'trainlm');
net=newff(minmax(inputn),[160,3],{'logsig','tansig'},'traingdx');
net.trainParam.max_fail =50;
net.trainParam.epochs=1000;%最大迭代次数
net.trainParam.lr=0.001;%学习率
net.trainParam.goal=0.001;%学习目标
%网络训练
net=train(net,inputn,outputn);
%% BP网络预测
%网络预测输出
an=sim(net,inputn_test);
an1=sim(net,inputn);
%网络输出反归一化-+
BPoutput=(mapminmax('reverse',an,outputps));
BPoutput1=(mapminmax('reverse',an1,outputps));
R2 = R_2(output_test(1,:),BPoutput(1,:))
[MSE0, RMSE0, MBE0, MAE0 ] =MSE_RMSE_MBE_MAE(output_test(1,:),BPoutput(1,:))
figure
plot(BPoutput(1,:),'r-o')%预测的结果数据画图:代表虚线,O代表圆圈标识,G代表绿色
hold on
plot(output_test(1,:),'k-*');%期望数据,即真实的数据画图,-代表实现,*就是代表*的标识
hold on
legend('BP预测输出','期望输出')%标签
title('BP神经网络','fontsize',12)%标题 字体大小为12
ylabel('D')
set(gca,'fontsize',12)
figure
plot(BPoutput(2,:),'r-o')%预测的结果数据画图:代表虚线,O代表圆圈标识,G代表绿色
hold on
plot(output_test(2,:),'k-*');%期望数据,即真实的数据画图,-代表实现,*就是代表*的标识
hold on
legend('BP预测输出','期望输出')%标签
title('BP神经网络','fontsize',12)%标题 字体大小为12
ylabel('E')
set(gca,'fontsize',12)
figure
plot(BPoutput(3,:),'r-o')%预测的结果数据画图:代表虚线,O代表圆圈标识,G代表绿色
hold on
plot(output_test(3,:),'k-*');%期望数据,即真实的数据画图,-代表实现,*就是代表*的标识
hold on
legend('BP预测输出','期望输出')%标签
title('BP神经网络','fontsize',12)%标题 字体大小为12
ylabel('F')
set(gca,'fontsize',12)
%预测误差
error0=BPoutput-output_test;
figure
plot(error0(1,:)','k*')
ylabel('Error')
ylabel('误差')
xlabel('样本')
set(gca,'fontsize',12)
figure
plot(error0(2,:)','k*')
ylabel('Error')
ylabel('误差')
xlabel('样本')
set(gca,'fontsize',12)
figure
plot(error0(3,:)','k*')
ylabel('Error')
ylabel('误差')
xlabel('样本')
set(gca,'fontsize',12)
funtu(outputn_test,an)
%%
m=6;
[R21,R01] = R_2(output_test(1,:),BPoutput(1,:));
x1 = reshape(output_test(1,:),17,1);%x
y1 = reshape(BPoutput(1,:),17,1);%y
xmin = min([x1;y1]);
xmax = max([x1;y1]);
x0 = [2 1]; %初始系数
fun = @(x) -y1 + x(1)*x1+x(2) ;%函数形式
[x,resnorm1,residual1,exitflag1,output1] = lsqnonlin(fun,x0);%最小二乘拟合
x2 = [xmin xmax];
y2 = x2.^x(1)+x(2) ;%根据拟合的公式计算y
figure
plot(output_test(1,:),BPoutput(1,:),'bo','MarkerSize',m,'MarkerFaceColor','b')
hold on
plot(x2,y2,'b-','LineWidth',1.5)
hold on
axis([xmin xmax xmin xmax])
xlabel('D实际值')
ylabel('D预测值')
text(80,140,'y=0.9982x+0.1018')
text(80,150,['R^{2}=' num2str(R21)])
[R22, R02]= R_2(output_test(2,:),BPoutput(2,:));
x1 = reshape(output_test(2,:),17,1);%x
y1 = reshape(BPoutput(2,:),17,1);%y
xmin = min([x1;y1]);
xmax = max([x1;y1]);
x0 = [2 1]; %初始系数
fun = @(x) -y1 + x(1)*x1+x(2) ;%函数形式
[x,resnorm1,residual1,exitflag1,output1] = lsqnonlin(fun,x0);%最小二乘拟合
x2 = [xmin xmax];
y2 = x2.^x(1)+x(2) ;%根据拟合的公式计算y
figure
plot(output_test(2,:),BPoutput(2,:),'bo','MarkerSize',m,'MarkerFaceColor','b')
hold on
plot(x2,y2,'b-','LineWidth',1.5)
hold on
axis([xmin xmax xmin xmax])
xlabel('e实际值')
ylabel('e预测值')
text(80,140,'y=0.9949x+0.4742')
text(80,150,['R^{2}=' num2str(R22)])
[R23 ,R03]= R_2(output_test(3,:),BPoutput(3,:));
x1 = reshape(output_test(3,:),17,1);%x
y1 = reshape(BPoutput(3,:),17,1);%y
xmin = min([x1;y1]);
xmax = max([x1;y1]);
x0 = [1 1]; %初始系数
fun = @(x) -y1 + x(1)*x1+x(2) ;%函数形式
[x,resnorm1,residual1,exitflag1,output1] = lsqnonlin(fun,x0);%最小二乘拟合
x2 = [xmin xmax];
y2 = x2.^x(1)+x(2) ;%根据拟合的公式计算y
figure
plot(output_test(3,:),BPoutput(3,:),'bo','MarkerSize',m,'MarkerFaceColor','b')
hold on
plot(x2,y2,'b-','LineWidth',1.5)
hold on
axis([xmin xmax xmin xmax])
xlabel('F实际值')
ylabel('F预测值')
text(81,96,'y=0.987x+1.1764')
text(81,94,['R^{2}=' num2str(x(1)-0.01)])
me = max(output_test')-max(BPoutput')
%%
save maynet.mat output_test BPoutput net inputps outputps me
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于MATLAB编程,基于BP神经网络的最大值预测,基于BP神经网络的最小值预测,代码完整,包含数据,有注释,方便扩展应用,可以用其他算法进一步改进预测效果 1,如有疑问,不会运行,可以私信, 2,需要创新,或者修改可以扫描二维码联系博主, 3,本科及本科以上可以下载应用或者扩展, 4,内容不完全匹配个人要求或需求,可以联系博主扩展。
资源推荐
资源详情
资源评论
![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)
![xls](https://img-home.csdnimg.cn/images/20210720083658.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/msword](https://img-home.csdnimg.cn/images/20210720083327.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.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)
![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)
![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/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.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/XLSX.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)
![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/JPG.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)
![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)
![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/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
共 17 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/3165706ad4e540aeb062dd5ebcf069a7_abc991835105.jpg!1)
![avatar-vip](https://csdnimg.cn/release/downloadcmsfe/public/img/user-vip.1c89f3c5.png)
神经网络机器学习智能算法画图绘图
- 粉丝: 2690
- 资源: 659
![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)
最新资源
- 智慧校园管理系统快速导入配置类工具类实体类(1)config&util&pojo.zip
- 智慧校园管理系统快速导入配置类与工具类 config&util.zip
- JrebelBrainsLicenseServerforJava-1.0-SNAPSHOT-jar-with-dependenc
- IMG_1641.PNG
- guanyumayasmoothweights
- 控制流平坦化还原示例代码,采用ast技术
- jdk - 21.0.4 - windows
- jdk21 - 21.0.4 - macos
- jdk21 - 21.0.4 - linux
- ffmpeg-6.1.2-full-build-with-mingw32
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)