基于模糊神经网络的时间序列预测(以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等。

相关推荐
geovindu3 分钟前
CSharp: Command Pattern
开发语言·后端·c#·.net·.netcore·命令模式·行为模式
angered5 分钟前
「AI 应用 / AI Agent」行业日报 · 2026-09-04
人工智能·ai编程
深海鱼肝油ya6 分钟前
向量数据库Elasticsearch(一)
人工智能·elasticsearch·向量数据库·es数据库增加索引·es数据库相似度查询·knn查询
residual_fan6 分钟前
持续对比强化学习(Continual Contrastive Reinforcement Learning)论文分享
人工智能·算法·数据挖掘·数据分析
深维AI随笔9 分钟前
《构建之法》| 第六章敏捷流程:敏捷不是“快“,而是“响应变化“,AI时代怎么敏捷
人工智能·敏捷流程·构建之法
Raas10012 分钟前
AI网关和LLM网关区别?MAI Gateway(魔芋企业级AI网关)企业级方案对比指南
大数据·人工智能·gateway·mai gateway·企业级产品
imbackneverdie15 分钟前
国内有哪些比较全面的生物医学相关数据库?
大数据·数据库·人工智能·ai·信息可视化·aigc·科研
心易行者21 分钟前
Python自动化测试7步落地法:用python在线运行省掉90%环境配置时间
java·开发语言·人工智能·python·log4j·ai编程
茗鹤APS和MES21 分钟前
工业排产:AI可赋能,APS不可替代
人工智能·深度学习·机器学习
东离与糖宝23 分钟前
深度拆解Claude Code架构:不靠总管,靠边界搭建编程Agent
人工智能