当前位置:网站首页>Analysis of 43 cases of MATLAB neural network: Chapter 32 time series prediction of wavelet neural network - short-term traffic flow prediction
Analysis of 43 cases of MATLAB neural network: Chapter 32 time series prediction of wavelet neural network - short-term traffic flow prediction
2022-06-24 09:43:00 【mozun2020】
《MATLAB neural network 43 A case study 》: The first 32 Chapter Time series prediction based on wavelet neural network —— Short term traffic flow forecast
1. Preface
《MATLAB neural network 43 A case study 》 yes MATLAB Technology Forum (www.matlabsky.com) planning , Led by teacher wangxiaochuan ,2013 Beijing University of Aeronautics and Astronautics Press MATLAB A book for tools MATLAB Example teaching books , Is in 《MATLAB neural network 30 A case study 》 On the basis of modification 、 Complementary , Adhering to “ Theoretical explanation — case analysis — Application extension ” This feature , Help readers to be more intuitive 、 Learn neural networks vividly .
《MATLAB neural network 43 A case study 》 share 43 Chapter , The content covers common neural networks (BP、RBF、SOM、Hopfield、Elman、LVQ、Kohonen、GRNN、NARX etc. ) And related intelligent algorithms (SVM、 Decision tree 、 Random forests 、 Extreme learning machine, etc ). meanwhile , Some chapters also cover common optimization algorithms ( Genetic algorithm (ga) 、 Ant colony algorithm, etc ) And neural network . Besides ,《MATLAB neural network 43 A case study 》 It also introduces MATLAB R2012b New functions and features of neural network toolbox in , Such as neural network parallel computing 、 Custom neural networks 、 Efficient programming of neural network, etc .
In recent years, with the rise of artificial intelligence research , The related direction of neural network has also ushered in another upsurge of research , Because of its outstanding performance in the field of signal processing , The neural network method is also being applied to various applications in the direction of speech and image , This paper combines the cases in the book , It is simulated and realized , It's a relearning , I hope I can review the old and know the new , Strengthen and improve my understanding and practice of the application of neural network in various fields . I just started this book on catching more fish , Let's start the simulation example , Mainly to introduce the source code application examples in each chapter , This paper is mainly based on MATLAB2015b(32 position ) Platform simulation implementation , This is an example of wavelet neural network time series prediction in Chapter 32 of this book , Don't talk much , Start !
2. MATLAB Simulation example
open MATLAB, Click on “ Home page ”, Click on “ open ”, Find the sample file 
Choose wavenn.m, Click on “ open ”
wavenn.m Source code is as follows :
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function : This code is a traffic flow prediction code based on wavelet neural network
% Environmental Science :Win7,Matlab2015b
%Modi: C.S
% Time :2022-06-20
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This code is a traffic flow prediction code based on wavelet neural network
%
% <html>
% <table border="0" width="600px" id="table1"> <tr> <td><b><font size="2"> The author of the case states that :</font></b></td> </tr> <tr><td><span class="comment"><font size="2">1: I have been stationed here for a long time <a target="_blank" href="http://www.ilovematlab.cn/forum-158-1.html"><font color="#0000FF"> plate </font></a> in , Ask questions about the case , Answer every question . The official website of this set of books is :<a href="http://video.ourmatlab.com">video.ourmatlab.com</a></font></span></td></tr><tr> <td><font size="2">2: Click here <a href="http://union.dangdang.com/transfer/transfer.aspx?from=P-284318&backurl=http://www.dangdang.com/"> Book from Dangdang </a>:<a href="http://union.dangdang.com/transfer/transfer.aspx?from=P-284318&backurl=http://www.dangdang.com/">《Matlab neural network 30 A case study 》</a>.</td></tr><tr> <td><p class="comment"></font><font size="2">3</font><font size="2">: This case has a supporting teaching video , Video download method <a href="http://video.ourmatlab.com/vbuy.html">video.ourmatlab.com/vbuy.html</a></font><font size="2">. </font></p></td> </tr> <tr> <td><span class="comment"><font size="2"> 4: This case is an original case , Reprint please indicate the source (《Matlab neural network 30 A case study 》).</font></span></td> </tr> <tr> <td><span class="comment"><font size="2"> 5: If this case happens to be relevant to your research , We welcome your comments , Requirement etc. , After we consider it, we can add it to the case .</font></span></td> </tr> </table>
% </html>
%% Clear environment variables
clc
clear
tic
%% Network parameter configuration
load traffic_flux input output input_test output_test
M=size(input,2); % Number of input nodes
N=size(output,2); % Number of output nodes
n=6; % Number of invisible nodes
lr1=0.01; % Learning probability
lr2=0.001; % Learning probability
maxgen=100; % The number of iterations
% Weight initialization
Wjk=randn(n,M);Wjk_1=Wjk;Wjk_2=Wjk_1;
Wij=randn(N,n);Wij_1=Wij;Wij_2=Wij_1;
a=randn(1,n);a_1=a;a_2=a_1;
b=randn(1,n);b_1=b;b_2=b_1;
% Node initialization
y=zeros(1,N);
net=zeros(1,n);
net_ab=zeros(1,n);
% Initialization of weight learning increment
d_Wjk=zeros(n,M);
d_Wij=zeros(N,n);
d_a=zeros(1,n);
d_b=zeros(1,n);
%% Input and output data normalization
[inputn,inputps]=mapminmax(input');
[outputn,outputps]=mapminmax(output');
inputn=inputn';
outputn=outputn';
error=zeros(1,maxgen);
%% Network training
for i=1:maxgen
% Error accumulation
error(i)=0;
% Cycle training
for kk=1:size(input,1)
x=inputn(kk,:);
yqw=outputn(kk,:);
for j=1:n
for k=1:M
net(j)=net(j)+Wjk(j,k)*x(k);
net_ab(j)=(net(j)-b(j))/a(j);
end
temp=mymorlet(net_ab(j));
for k=1:N
y=y+Wij(k,j)*temp; % Wavelet function
end
end
% Calculation error and
error(i)=error(i)+sum(abs(yqw-y));
% Weight adjustment
for j=1:n
% Calculation d_Wij
temp=mymorlet(net_ab(j));
for k=1:N
d_Wij(k,j)=d_Wij(k,j)-(yqw(k)-y(k))*temp;
end
% Calculation d_Wjk
temp=d_mymorlet(net_ab(j));
for k=1:M
for l=1:N
d_Wjk(j,k)=d_Wjk(j,k)+(yqw(l)-y(l))*Wij(l,j) ;
end
d_Wjk(j,k)=-d_Wjk(j,k)*temp*x(k)/a(j);
end
% Calculation d_b
for k=1:N
d_b(j)=d_b(j)+(yqw(k)-y(k))*Wij(k,j);
end
d_b(j)=d_b(j)*temp/a(j);
% Calculation d_a
for k=1:N
d_a(j)=d_a(j)+(yqw(k)-y(k))*Wij(k,j);
end
d_a(j)=d_a(j)*temp*((net(j)-b(j))/b(j))/a(j);
end
% Weight parameter update
Wij=Wij-lr1*d_Wij;
Wjk=Wjk-lr1*d_Wjk;
b=b-lr2*d_b;
a=a-lr2*d_a;
d_Wjk=zeros(n,M);
d_Wij=zeros(N,n);
d_a=zeros(1,n);
d_b=zeros(1,n);
y=zeros(1,N);
net=zeros(1,n);
net_ab=zeros(1,n);
Wjk_1=Wjk;Wjk_2=Wjk_1;
Wij_1=Wij;Wij_2=Wij_1;
a_1=a;a_2=a_1;
b_1=b;b_2=b_1;
end
end
%% Network prediction
% Prediction input normalization
x=mapminmax('apply',input_test',inputps);
x=x';
yuce=zeros(92,1);
% Network prediction
for i=1:92
x_test=x(i,:);
for j=1:1:n
for k=1:1:M
net(j)=net(j)+Wjk(j,k)*x_test(k);
net_ab(j)=(net(j)-b(j))/a(j);
end
temp=mymorlet(net_ab(j));
for k=1:N
y(k)=y(k)+Wij(k,j)*temp ;
end
end
yuce(i)=y(k);
y=zeros(1,N);
net=zeros(1,n);
net_ab=zeros(1,n);
end
% Inverse normalization of prediction output
ynn=mapminmax('reverse',yuce,outputps);
%% Result analysis
figure(1)
plot(ynn,'r*:')
hold on
plot(output_test,'bo--')
title(' Forecast traffic flow ','fontsize',12)
legend(' Forecast traffic flow ',' Actual traffic flow ','fontsize',12)
xlabel(' Point in time ')
ylabel(' traffic flow ')
toc
% web browser www.matlabsky.com
%%
% <html>
% <table width="656" align="left" > <tr><td align="center"><p><font size="2"><a href="http://video.ourmatlab.com/">Matlab neural network 30 A case study </a></font></p><p align="left"><font size="2"> Related forums :</font></p><p align="left"><font size="2">《Matlab neural network 30 A case study 》 Official website :<a href="http://video.ourmatlab.com">video.ourmatlab.com</a></font></p><p align="left"><font size="2">Matlab Technology Forum :<a href="http://www.matlabsky.com">www.matlabsky.com</a></font></p><p align="left"><font size="2">M</font><font size="2">atlab Encyclopedia of functions :<a href="http://www.mfun.la">www.mfun.la</a></font></p><p align="left"><font size="2">Matlab Chinese Forum :<a href="http://www.ilovematlab.com">www.ilovematlab.com</a></font></p></td> </tr></table>
% </html>
The source code of the calling function is as follows :
% The two subroutines used here are :
function y=mymorlet(t)
y = exp(-(t.^2)/2) * cos(1.75*t);
function y=d_mymorlet(t)
y = -1.75*sin(1.75*t).*exp(-(t.^2)/2)-t* cos(1.75*t).*exp(-(t.^2)/2) ;
Add completed , Click on “ function ”, Start emulating , The output simulation results are as follows :
3. Summary
Wavelet neural network (Wavelet Neural Network, WNN) It is an artificial neural network based on the breakthrough of wavelet analysis . It is based on the theory of wavelet analysis and wavelet transform 、 A new multi-resolution artificial neural network model . That is to say, the nonlinear wavelet basis is used to replace the usual nonlinear Sigmoid function , The signal representation is expressed by linear superposition of the selected wavelet bases . It avoids the BP The blindness and local optimization of neural network structure design , Greatly simplifies training , It has strong function learning ability, generalization ability and broad application prospect . Wavelet transform is also widely used in image processing and speech recognition , Please refer to the following links for details . Interested in the content of this chapter or want to fully learn and understand , It is suggested to study the contents of Chapter 32 in the book . Some of these knowledge points will be supplemented on the basis of their own understanding in the later stage , Welcome to study and exchange together .
边栏推荐
猜你喜欢

二十、处理器调度(RR时间片轮转,MLFQ多级反馈队列,CFS完全公平调度器,优先级翻转;多处理器调度)

About thinkphp5, use the model save() to update the data prompt method not exist:think\db\query- & gt; Error reporting solution

如何管理海量的网络基础设施?

如何解决独立站多渠道客户沟通难题?这款跨境电商插件一定要知道!

PRCT-1400 : 未能执行 getcrshome解决方法

Ggplot2 color setting summary

5分钟,客服聊天处理技巧,炉火纯青

《MATLAB 神经网络43个案例分析》:第32章 小波神经网络的时间序列预测——短时交通流量预测

ggplot2颜色设置总结

最新Windows下Go语言开发环境搭建+GoLand配置
随机推荐
Oracle数据库EXPDP只导出表的方法
Weekly recommended short video: talk about "meta universe" with a serious attitude
深度学习论文阅读目标检测篇(七)中英对照版:YOLOv4《Optimal Speed and Accuracy of Object Detection》
生产者/消费者模型
leetcode--字符串
Zero foundation self-study SQL course | sub query
Time series data augmentation for deep learning: paper reading of a survey
最新Windows下Go语言开发环境搭建+GoLand配置
Zero foundation self-study SQL course | having clause
Grpc local test joint debugging tool bloomrpc
impdp导schema报ORA-31625异常处理
198. 打家劫舍
When should gridfs be used?
LeetCode: 377. 组合总和 Ⅳ
R 椭圆随机点产生并画图
可直接套用的Go编码规范
ThinkPHP 5.0 模型关联详解
Oracle数据库监听文件配置
实战剖析:app扫码登陆实现原理(app+网页端详细逻辑)附源码
CF566E-Restoring Map【bitset】