clc; clear all; close all;
warning off all;
rand('seed', 10);
load enso;
data_x = month';
data_y = pressure';
mu = mean(data_y);
sig = std(data_y);
data_y = (data_y - mu) / sig;
wd = 5;
len = numel(data_y);
wdata = [];
for i = 1 : 1 : len - wd
di = data_y(i:i+wd);
wdata = [wdata; di];
end
wdata_origin = wdata;
index_list = randperm(size(wdata, 1));
ind = round(0.8*length(index_list));
train_index = index_list(1:ind);
test_index = index_list(ind+1:end);
train_index = sort(train_index);
test_index = sort(test_index);
dataTrain = wdata(train_index, :);
/*
????,?????,?????????????,????????,??????,???????,
???????????,WX:Q3101759565,QQ:3101759565
*/
Yall = wdata_origin(:, end)';
YPred = predict(net,Xall,'MiniBatchSize',1);
rmse = mean((YPred(:)-Yall(:)).^2);
figure
subplot(2,1,1)
plot(data_x(1:length(Yall)), Yall)
hold on
plot(data_x(1:length(Yall)),YPred,'.-')
hold off
legend(['Real' 'Predict'])
ylabel('Data')
title(sprintf('LSTM分析-RMSE=%.2f', rmse));
subplot(2,1,2)
stem(data_x(1:length(Yall)), YPred - Yall)
xlabel('Time')
ylabel('Error')
title('LSTM分析-误差图');
没有合适的资源?快使用搜索试试~ 我知道了~
基于长短期记忆网络(LSTM)对时间序列的预测分析(MATLAB)
共3个文件
m:3个
需积分: 5 1 下载量 147 浏览量
2024-03-11
15:57:26
上传
评论
收藏 3KB ZIP 举报
温馨提示
该程序实现了长短期记忆网络(LSTM)模型的搭建,并实现对时间序列数据进行训练和预测功能。
资源推荐
资源详情
资源评论
收起资源包目录
基于长短期记忆网络(LSTM)对时间序列的预测分析(MATLAB).zip (3个子文件)
基于长短期记忆网络(LSTM)对时间序列的预测分析(MATLAB)
main_lstm.m 1KB
get_lstm_net.m 427B
main_spline.m 455B
共 3 条
- 1
资源评论
迪哥_AI_人工智能
- 粉丝: 584
- 资源: 145
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功