【时间序列预测】基于matlab RBF神经网络时间序列预测【含Matlab源码 1336期】
一、RBF神经网络简介
1 RBF网络
径向基函数(RBF)网络是一种向前网络,它以函数逼近理论为基础,能够逼近任意非线性的函数,同时具有很好的泛化能力和较快的学习速度。RBF神经网络由输入层、隐含层、输出层组成。输入层由输入节点组成,只传递输入信号到隐含层;隐含层由神经元的变换函数,如高斯函数、格林函数等辐射状作用函数构成,其中隐含层节点数由问题的实际需求来确定;输出层是对输入的响应,由输入节点组成。
RBF网络的主要思想是:将输入数据直接映射到隐含层空间,用径向基函数作为隐单元的“基”构成隐含层的空间,在此空间对输入数据进行变换,将在低维空间中的非线性数据变换为高维空间内线性可分。这种非线性的映射关系,通过径向基函数的中心点来确定。输出层则是通过隐含层的线性映射得到的,即网络的输出是隐含层神经单元输出的线性加权和。具体结构如图1所示。
图1 RBF神经网络结构
隐含层节点中的作用函数(基函数)对输入信号将在局部产生响应。最常用的基函数是高斯函数,如下:
式中:x是n维输入向量;ci是第i个基函数的中心,与x具有相同维数的向量;σi是第i个感知的变量,决定基函数中心点的宽度;m是感知单元的个数;
令输入层实现从x→Ri(x)的非线性映射,隐含层实现从Ri(x)到yk的线性映射,即:
式中:r是输出节点数;wik是权值。
由上述RBF网络的原理可知,RBF网络主要涉及三种可调参数:RBF的中心向量ci、偏值σi、隐含层到输出层的权重wik。其中,RBF的中心ci的选取对网络性能至关重要,中心太近,会产生近似线性相关;中心太远,产生的网络会过大。根据这三种参数的确定,可以将RBF网络划分为很多种学习方法,最常见的是:随机选取中心法、自组织选取中心法、有监督选取中心法和正交最小二乘法(OLS)。
2 时间序列的RBF神经网络预测
基于RBF神经网络的时间序列预测模型,最主要的是需要确定好训练样本的输入和输出。为预测时间序列y(i)的值,以X(i)=[y(i-n),y(i-n+1),…,y(i-1)]T作为输入,n为历史数据长度,代表过去n天的历史数据。因此网络结构[11]可以表示为y(i)=f(y(in),y(i-n+1),…,y(i-1))。
由于时间序列有一定的复杂性,而且序列数据前后的关联程度大不相同。因此,采用不同的历史数据长度的预测模型,结果大相径庭。本文分别采用不同的历史数据长度,选取其中预测结果均方误差最小的历史数据长度,提高模型的预测性能。
二、部分源代码
%% Mackey Glass Time Series Prediction using Spatio-Temporal Radial Basis Function (RBF) Neural Network
% Author: Shujaat Khan, shujaat123@gmail.comclc;
clear all;
close all;%% Loading Time Series Data
% I generated a series x(t) for t = 0,1, . . . ,3000, using mackey glass series equation with the following configurations: b = 0.1, a = 0.2, Tau = 20, and the initial conditions x(t - Tau) = 0.
load Dataset/Data.mat% Training and Test datasets
time_steps=2; % prediction of #time_steps forward value (for this simple architechture time_steps<=3)
% Training
start_of_series_tr=100;
end_of_series_tr=2500;
% Test
start_of_series_ts=2500;
end_of_series_ts=3000;P_train=Data(start_of_series_tr:end_of_series_tr-time_steps,2); % Input Data
f_train=Data(start_of_series_tr+time_steps:end_of_series_tr,2); % Label Data (desired output values)
indt=Data(start_of_series_tr+time_steps:end_of_series_tr,1);% Time indexSNR = 30; % signal to noise ratio
f_train=awgn(f_train,SNR); % Adding white Gaussian noise%% Simulation parameters
% Defining architechture of the RBF-NN
[m n] = size(P_train);% Dimensions of input data [m]-length of signal, [n]-number of elements in each input
order=2; % Number of past values used for the prediction of future value
n1 = 10; % Number of hidden layer neurons% Tuning parameters for training
epoch=10; % simulation rounds (number of times the same data pass through the NN for training)
eta=5e-2; % Gradient Descent step-size (learning rate)
runs=10; % Number of Monte Carlo simulations
Iti=[]; % Initial mean square error (MSE)% Graphics/Plot parameters
fsize=13; % Fontsize
lw=2; % line width size%% Training Phase
for run=1:runs % Monte Carlos simulations loop% spread and centers of the Gaussian kernel [temp, c, beeta] = kmeans(P_train,n1); % K-means clustering
% c=[c awgn(c,10)];beeta=2*beeta; % Increasing spread of Gaussian kernel% Initialization of weights and biasw=randn(order,n1); % weightb=randn(); % biasfor k=1:epoch % simulation rounds loopI(k)=0; % reset MSEU=zeros(1,order); % reset input vectorfor i1=1:m % Iteration loop% sliding window (updating input vector)U(1:end-1)=U(2:end);U(end)=P_train(i1); % current value of time-series% Gaussian Kernelfor i2=1:n1phi(:,i2)=exp((-(abs(U-c(i2,:))))/beeta(i2,:).^2);end% Calculate output of the RBFy_train(i1)=sum(sum(w.*phi))+b;e(i1)=f_train(i1)-y_train(i1); % instantaneous error in the prediction% Gradient descent-based weight-update rulew=w+eta*e(i1)*phi;b=b+eta*e(i1);% Mean square error I(i1)=mse(e(1:i1)); % Objective FunctionendItti(epoch,:)=I; % MSE for all iterationsendIti(run,:)=mean(Itti,1); % Mean MSE for all epochs
end
It=mean(Iti,1); % Mean MSE for all independent runs (Monte Carlo simulations)%% Test Phase
P_test=Data(start_of_series_ts:end_of_series_ts-time_steps,2);
f_test=Data(start_of_series_ts+time_steps:end_of_series_ts,2);
indts=Data(start_of_series_ts+time_steps:end_of_series_ts,1);[m n] = size(P_test);
for i1=1:m % Iteration loop% sliding window (updating input vector) U(1:end-1)=U(2:end);U(end)=P_test(i1);for i2=1:n1phi(:,i2)=exp((-(abs(U-c(i2,:))))/beeta(i2,:).^2);endy_test(i1)=sum(sum(w.*phi))+b;e_test(i1)=real(f_test(i1)-y_test(i1));I(2400+i1)=mse(e_test(1:i1));
endsave ST_RBF.mat
% %% Results
% % Input and output signals (training phase)
% figure
% plot(indt,f_train,'k','linewidth',lw);
% hold on;
% plot(indt,y_train,'.:b','linewidth',lw);
% xlim([start_of_series_tr+time_steps end_of_series_tr]);
% h=legend('Actual Value (Training)','RBF Predicted (Training)','Location','Best');
% grid minor
% xlabel('Sample #','FontSize',fsize);
% ylabel('Magnitude','FontSize',fsize);
% set(h,'FontSize',12)
% set(gca,'FontSize',13)
% saveas(gcf,strcat('Time_SeriesTraining.png'),'png')
%
% % Input and output signals (test phase)
% figure
% plot(indts,f_test,'k','linewidth',lw);
% hold on;
% plot(indts,y_test,'.:b','linewidth',lw);
% xlim([start_of_series_ts+time_steps end_of_series_ts]);
% h=legend('Actual Value (Testing)','RBF Predicted (Testing)','Location','Best');
% grid minor
% xlabel('Sample #','FontSize',fsize);
% ylabel('Magnitude','FontSize',fsize);
% set(h,'FontSize',12)
% set(gca,'FontSize',13)
% saveas(gcf,strcat('Time_SeriesTesting.png'),'png')
%
% % Objective function (MSE) (training phase)
% figure
% plot(start_of_series_tr:end_of_series_tr-1,10*log10(I(1:end_of_series_tr-start_of_series_tr)),'+-b','linewidth',lw)
% h=legend('RBF (Training)','Location','North');
% grid minor
% xlabel('Sample #','FontSize',fsize);
% ylabel('MSE (dB)','FontSize',fsize);
% set(h,'FontSize',12)
% set(gca,'FontSize',13)
% saveas(gcf,strcat('Time_SeriesTrainingMSE.png'),'png')
%
% % Objective function (MSE) (test phase)
% figure
% plot(start_of_series_ts+time_steps:end_of_series_ts,10*log10(I(end_of_series_tr-start_of_series_tr+1:end)),'.:b','linewidth',lw+1)
% h=legend('RBF (Testing)','Location','South');
% grid minor
% xlabel('Sample #','FontSize',fsize);
% ylabel('MSE (dB)','FontSize',fsize);
% set(h,'FontSize',12)
% set(gca,'FontSize',13)
% saveas(gcf,strcat('Time_SeriesTestingMSE.png'),'png')
%
% % Mean square error
% 10*log10(((f_train'-y_train)*(f_train'-y_train)')/length(y_train))
% 10*log10(((f_test'-y_test)*(f_test'-y_test)')/length(y_test))Results_graphs
三、运行结果
四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 包子阳,余继周,杨杉.智能优化算法及其MATLAB实例(第2版)[M].电子工业出版社,2016.
[2]张岩,吴水根.MATLAB优化算法源代码[M].清华大学出版社,2017.
[3]周品.MATLAB 神经网络设计与应用[M].清华大学出版社,2013.
[4]陈明.MATLAB神经网络原理与实例精解[M].清华大学出版社,2013.
[5]方清城.MATLAB R2016a神经网络设计与应用28个案例分析[M].清华大学出版社,2018.
[6]黄伟建,张丽娜,黄远,程瑶.RBF神经网络在河流营养盐预测中的应用[J].现代电子技术. 2019,42(20)
【时间序列预测】基于matlab RBF神经网络时间序列预测【含Matlab源码 1336期】相关推荐
- 【Matlab电力负荷预测】粒子群优化支持向量机短期电力负荷预测【含GUI源码 751期】
一.代码运行视频(哔哩哔哩) [Matlab电力负荷预测]粒子群优化支持向量机短期电力负荷预测[含GUI源码 751期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 ...
- 【Matlab人脸识别】BP神经网络人脸识别(含识别率)【含GUI源码 891期】
一.代码运行视频(哔哩哔哩) [Matlab人脸识别]BP神经网络人脸识别(含识别率)[含GUI源码 891期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1] ...
- 【Matlab树叶分类】BP神经网络植物叶片分类【含GUI源码 916期】
一.代码运行视频(哔哩哔哩) [Matlab树叶分类]BP神经网络植物叶片分类[含GUI源码 916期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1] 蔡利梅 ...
- 【Matlab验证码识别】遗传算法和最大熵优化+大津法(OTSU)+自定义阈值数字验证码识别【含GUI源码 1694期】
一.代码运行视频(哔哩哔哩) [Matlab验证码识别]遗传算法和最大熵优化+大津法(OTSU)+自定义阈值数字验证码识别[含GUI源码 1694期] 二.matlab版本及参考文献 1 matlab ...
- 【Matlab人脸识别】形态学教室人数统计(带面板)【含GUI源码 1703期】
一.代码运行视频(哔哩哔哩) [Matlab人脸识别]形态学教室人数统计(带面板)[含GUI源码 1703期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]孟 ...
- 【Matlab人脸识别】人脸实时检测与跟踪【含GUI源码 673期】
一.代码运行视频(哔哩哔哩) [Matlab人脸识别]人脸实时检测与跟踪[含GUI源码 673期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]孟逸凡,柳益君 ...
- 【Matlab身份证识别】身份证号码识别【含GUI源码 014期】
一.代码运行视频(哔哩哔哩) [Matlab身份证识别]身份证号码识别[含GUI源码 014期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1] 蔡利梅.MAT ...
- 【Matlab生物电信号】生物电信号仿真【含GUI源码 684期】
一.代码运行视频(哔哩哔哩) [Matlab生物电信号]生物电信号仿真[含GUI源码 684期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]董兵,超于毅,李 ...
- 【Matlab语音分析】语音信号分析【含GUI源码 1718期】
一.代码运行视频(哔哩哔哩) [Matlab语音分析]语音信号分析[含GUI源码 1718期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1]韩纪庆,张磊,郑铁 ...
- 【Matlab图像融合】小波变换遥感图像融合【含GUI源码 744期】
一.代码运行视频(哔哩哔哩) [Matlab图像融合]小波变换遥感图像融合[含GUI源码 744期] 二.matlab版本及参考文献 1 matlab版本 2014a 2 参考文献 [1] 包子阳,余 ...
最新文章
- 在Ubuntu 12.04 64bit上搭建Crtmpserver视频直播服务
- Oracle 原理: 11g的启动和关闭
- 【好记性不如烂笔头】之小程序要点记录
- iis 7.5应用程序池自动停止
- free网页服务器,Web网站服务(一)
- ajax中datatype是json,dataType:'json'vs data:$ .ajax中的JSON.stringify(obj)
- 旅游流的概念_2020年去张家界凤凰古城旅游亲身体验经历分享——实用攻略(图文)...
- hdu1535 Invitation Cards 最短路
- R语言中样本平衡的几种方法
- 单机数据库优化的一些实践
- bfc -- 块级格式化上下文
- python37安装失败怎么搞_Linux 安装Python37
- f5 系统损坏,重新安全系统
- linux界面程序崩溃,Linux 下安装anjuta程序运行崩溃 只能用glade做界面
- 渲染用计算机功耗,【IT之家评测室】满功耗 RTX 3060 笔记本 GPU 表现如何?拯救者 R9000P 实测...
- 高级启动选项重装计算机,如何使用高级选项重装win10系统?重装win10系统方法...
- python疫情监控(爬虫+可视化)
- 基于Laravel开发的Diy手机壳在线定制系统源码
- 孕妇适合吃哪些蔬菜?这三种蔬菜很有营养
- 手机配指环条码阅读器的爱恨纠缠
热门文章
- django 标签的使用
- 委托应用及泛型委托和多播委托
- JavaScript运动应用一
- poj 2996 Help Me with the Game 模拟
- EOJ-1708//POJ3334
- 思考问题的一些方法:一般化,特殊化和归纳类比
- IE 6里面当高度(height)小于9px时,高度会仍然是9px[解决办法]
- 七月算法机器学习 (16)人工神经网络
- 如何选择适合自己的相机?
- Atitit 提升开发效率 提升团队人员能力 目录 1. 多语言扩展 提升抽象度	2 2. 从上到下法 vs 从下倒上 问题诊断解决法	2 2.1. 培训机制 上到下法	2 2.2. 问题案例