基于模糊神经网络的时间序列预测(以hopkinsirandeath数据集为例,MATLAB)

模糊神经网络从提出发展到今天,主要有三种形式:算术神经网络、逻辑模糊神经网络和混合模糊神经网络。算术神经网络是最基本的,它主要是对输入量进行模糊化,且网络结构中的权重也是模糊权重;逻辑模糊神经网络的主要特点是模糊权值可以进行逻辑运算操作;混合模糊神经网络是对于基本的模糊神经网络而言,其内的传统函数和模糊权值的运算都是随意的不同的。模糊神经网络发展到今天,已经从理论研究应用到工业生产和人们生活中的各个领域。模糊神经网络已经在模式识别、图像处理、工业控制生产等各个领域取得了不少成果。

鉴于此,采用Takagi Sugeno Kang模糊神经网络对时间序列进行预测,以hopkinsirandeat数据为例进行说明,程序运行环境为MATLAB R2021B。主运行代码如下:

Matlab 复制代码
close all;clc;clear all
dat=load('hopkinsirandeath.txt')';
dat1=load('hopkinsiranconfirmed.txt')';
dat2=load('hopkinsiranrecovered.txt')';

% Nonlinear ARX model to fit
sys = nlarx(dat,64);
sys1 = nlarx(dat1,64);
sys2 = nlarx(dat2,64);

% Compare the simulated output of sys with measured data to ensure it is a good fit.
nstep = 40;
figure;
set(gcf, 'Position',  [50, 200, 1300, 400])
subplot(1,3,1)
compare(dat,sys,nstep);title('Covid Iran Death');
grid on;
subplot(1,3,2)
compare(dat1,sys1,nstep);title('Covid Iran Confirm');
grid on;
subplot(1,3,3)
compare(dat2,sys2,2);title('Covid Iran Recovered');
grid on;
% Forecast the values into the future for a given time horizon K.
% K is number of days 
K = 180;
opt = forecastOptions('InitialCondition','e');
[p,ForecastMSE] = forecast(sys,dat,K,opt);
[p1,ForecastMSE1] = forecast(sys1,dat1,K,opt);
[p2,ForecastMSE2] = forecast(sys2,dat2,K,opt);

datsize=size(dat);datsize=datsize(1,1);
ylbl=datsize+K;
t = linspace(datsize,ylbl,length(p));
figure;
set(gcf, 'Position',  [1, 1, 1000, 950])
subplot(3,1,1)
plot(dat,'--',...
    'LineWidth',1,...
    'MarkerSize',5,...
    'Color',[0,0,0]);
hold on;
plot(t,p,'-.',...
    'LineWidth',2,...
    'MarkerSize',10,...
    'MarkerEdgeColor','r',...
    'Color',[0.9,0,0]);
title('Johns Hopkins Data for Iran COVID Deaths - Red is Forcasted')
xlabel('Days - From Jan 2020 Till Dec 2021','FontSize',12,...
       'FontWeight','bold','Color','b');
ylabel('Number of People','FontSize',12,...
       'FontWeight','bold','Color','b');
   datetick('x','mmm');
legend({'Measured','Forecasted'});
    subplot(3,1,2)
plot(dat1,'--',...
    'LineWidth',1,...
    'MarkerSize',5,...
    'Color',[0,0,0]);
hold on;
plot(t,p1,'-.',...
    'LineWidth',2,...
    'MarkerSize',10,...
    'MarkerEdgeColor','r',...
    'Color',[0.9,0,0]);
title('Johns Hopkins Data for Iran COVID Confirmed - Red is Forcasted')
xlabel('Days - From Jan 2020 Till Dec 2021','FontSize',12,...
       'FontWeight','bold','Color','b');
ylabel('Number of People','FontSize',12,...
       'FontWeight','bold','Color','b');
   datetick('x','mmm');
legend({'Measured','Forecasted'});
subplot(3,1,3)
plot(dat2,'--',...
    'LineWidth',1,...
    'MarkerSize',5,...
    'Color',[0,0,0]);
hold on;
plot(t,p2,'-.',...
    'LineWidth',2,...
    'MarkerSize',10,...
    'MarkerEdgeColor','r',...
    'Color',[0.9,0,0]);
title('Johns Hopkins Data for Iran COVID Recovered - Red is Forcasted')
xlabel('Days - From Jan 2020 Till Dec 2021','FontSize',12,...
       'FontWeight','bold','Color','b');
ylabel('Number of People','FontSize',12,...
       'FontWeight','bold','Color','b');
   datetick('x','mmm');
legend({'Measured','Forecasted'});
%
finalpredict=[dat;p];
finalpredict1=[dat1;p1];
finalpredict2=[dat2;p2];

%% Predicting original and forcasted data using ANFIS (FCM)
[TrainTargets,TrainOutputs]=fuzzfcm(finalpredict);
figure;
set(gcf, 'Position',  [10, 50, 1100, 300])
Plotit(TrainTargets,TrainOutputs,'ANFIS Predict COVID Deaths');
%
[TrainTargets,TrainOutputs]=fuzzfcm(finalpredict1);
figure;
set(gcf, 'Position',  [50, 100, 1100, 300])
Plotit(TrainTargets,TrainOutputs,'ANFIS Predict COVID Confirmed');
%
[TrainTargets,TrainOutputs]=fuzzfcm(finalpredict2);
figure;
set(gcf, 'Position',  [70, 130, 1100, 300])
Plotit(TrainTargets,TrainOutputs,'ANFIS Predict COVID Recovered');

完整代码:https://mbd.pub/o/bread/mbd-ZJWWm5hv

擅长领域:现代信号处理,机器学习,深度学习,数字孪生,时间序列分析,设备缺陷检测、设备异常检测、设备智能故障诊断与健康管理PHM等。

相关推荐
微风中的麦穗1 天前
【MATLAB】MATLAB R2025a 详细下载安装图文指南:下一代科学计算与工程仿真平台
开发语言·matlab·开发工具·工程仿真·matlab r2025a·matlab r2025·科学计算与工程仿真
2601_949146531 天前
C语言语音通知API示例代码:基于标准C的语音接口开发与底层调用实践
c语言·开发语言
开源技术1 天前
Python Pillow 优化,打开和保存速度最快提高14倍
开发语言·python·pillow
学嵌入式的小杨同学1 天前
从零打造 Linux 终端 MP3 播放器!用 C 语言实现音乐自由
linux·c语言·开发语言·前端·vscode·ci/cd·vim
wearegogog1231 天前
基于MATLAB的CNN图像分类算法实现
matlab·分类·cnn
Niuguangshuo1 天前
深入解析Stable Diffusion基石——潜在扩散模型(LDMs)
人工智能·计算机视觉·stable diffusion
迈火1 天前
SD - Latent - Interposer:解锁Stable Diffusion潜在空间的创意工具
人工智能·gpt·计算机视觉·stable diffusion·aigc·语音识别·midjourney
wfeqhfxz25887821 天前
YOLO13-C3k2-GhostDynamicConv烟雾检测算法实现与优化
人工智能·算法·计算机视觉
芝士爱知识a1 天前
2026年AI面试软件推荐
人工智能·面试·职场和发展·大模型·ai教育·考公·智蛙面试
Li emily1 天前
解决港股实时行情数据 API 接入难题
人工智能·python·fastapi