当前位置: 首页 > news >正文

python 时间序列预测——Jordan循环神经网络

数据集

COE 下载参见 python 时间序列预测——简单神经网络

设定输入输出变量并归一化

from sklearn import preprocessing
import pandas as pd

loc= "COE.csv "
temp = pd.read_csv ( loc )
data= temp . drop ( temp . columns [ [ 0 , 1 ] ] , axis=1)

x=data.drop ( data . columns [ [ 0 , 4 ] ] , axis =1)
x=x.apply(np.log )
x=pd.concat ( [ x , data ['Open?' ] ] , axis=1)

scaler_x = preprocessing . MinMaxScaler (feature_range=(0 , 1) )
x = np .array ( x ) . reshape ( ( len ( x ) ,4 ) )
x = scaler_x . fit_transform ( x )

y=data ['COE$']
scaler_y = preprocessing . MinMaxScaler (feature_range=(0 , 1) )
y = np . array ( y ) . reshape ( ( len ( y ) , 1) )
y = np . log ( y )
y = scaler_y . fit_transform ( y )

y = y.tolist ( )
x = x.tolist ( )

JordanRecurrent

在这里插入图片描述
在这里插入图片描述

import random
from pyneurgen.neuralnet import NeuralNet
from pyneurgen.recurrent import JordanRecurrent

random . seed (2019)
model = NeuralNet ()
input_nodes = 4
hidden_nodes = 7
output_nodes = 1
existing_weight_factor = 0.9

model.init_layers (input_nodes,
    [hidden_nodes],
    output_nodes,
    JordanRecurrent(existing_weight_factor))
model. randomize_network ( )
model. layers[ 1 ] . set_activation_type('sigmoid')
model. set_learnrate(0.05)
model. set_all_inputs (x)
model. set_all_targets (y)

length = len ( x )
learn_end_point = int ( length * 0.95 )
model . set_learn_range ( 0 , learn_end_point )
model . set_test_range ( learn_end_point + 1 , length -1)
model . learn ( epochs =100 , show_epoch_results =True , random_testing = False )

mse = model. test ()
print(" test set MSE =",np.round(mse ,6))

target = np.array([ item [0][0] for item in fit1.test_targets_activations ])
pred = [ item [1][0] for item in fit1.test_targets_activations ]
# pred1 = scaler_y.inverse_transform (np.array( pred ). reshape((len(pred), 1)))  # 恢复
# pred1 = np.exp(pred1)

plt.plot(target)
plt.plot(pred)
plt.plot(target*1.05,'--g',target*0.95,'--g')
plt.legend(['target','prediction','CI'])

在这里插入图片描述

相关文章:

  • 强大的数据报表中心
  • python 时间序列预测——Elman循环神经网络
  • IFormatProvider 接口
  • python 时间序列预测——NARX循环神经网络
  • 好可爱啊
  • python 时间序列预测——LSTM, GRU
  • python 时间序列预测——多序列预测
  • 为什么美女喜欢软件开发的gg做老公
  • LINQ体验系列文章导航
  • python 绘制条形图
  • 一个很好的svn托管站点
  • Gephi:can’t find java 1.8 or higher
  • 尿飞顿作灵思涌
  • Gephi 网络可视化——导入网络结构
  • DataGrid中使用CheckBox的CheckedChanged事件
  • [译]Python中的类属性与实例属性的区别
  • linux安装openssl、swoole等扩展的具体步骤
  • rabbitmq延迟消息示例
  • Ruby 2.x 源代码分析:扩展 概述
  • thinkphp5.1 easywechat4 微信第三方开放平台
  • 分享几个不错的工具
  • 猫头鹰的深夜翻译:Java 2D Graphics, 简单的仿射变换
  • 每天10道Java面试题,跟我走,offer有!
  • 自定义函数
  • 湖北分布式智能数据采集方法有哪些?
  • ​​​​​​​GitLab 之 GitLab-Runner 安装,配置与问题汇总
  • ​html.parser --- 简单的 HTML 和 XHTML 解析器​
  • !!【OpenCV学习】计算两幅图像的重叠区域
  • ###C语言程序设计-----C语言学习(3)#
  • $.ajax()
  • (BFS)hdoj2377-Bus Pass
  • (JS基础)String 类型
  • (附源码)spring boot公选课在线选课系统 毕业设计 142011
  • (附源码)springboot美食分享系统 毕业设计 612231
  • (附源码)ssm失物招领系统 毕业设计 182317
  • (力扣记录)235. 二叉搜索树的最近公共祖先
  • (每日持续更新)jdk api之FileFilter基础、应用、实战
  • (十七)Flask之大型项目目录结构示例【二扣蓝图】
  • (学习日记)2024.01.19
  • (转)Java socket中关闭IO流后,发生什么事?(以关闭输出流为例) .
  • .360、.halo勒索病毒的最新威胁:如何恢复您的数据?
  • .NET/C# 在代码中测量代码执行耗时的建议(比较系统性能计数器和系统时间)
  • .NET中的Event与Delegates,从Publisher到Subscriber的衔接!
  • ??如何把JavaScript脚本中的参数传到java代码段中
  • @LoadBalanced 和 @RefreshScope 同时使用,负载均衡失效分析
  • [AI]ChatGPT4 与 ChatGPT3.5 区别有多大
  • [ajaxupload] - 上传文件同时附件参数值
  • [IE技巧] IE8中HTTP连接数目的变化
  • [ITIL学习笔记]之事件管理(2)
  • [leetcode] 103. 二叉树的锯齿形层次遍历
  • [LeetCode周赛复盘] 第 312 场周赛20220925
  • [Linux] PHP程序员玩转Linux系列-telnet轻松使用邮箱
  • [Linux_IMX6ULL应用开发]-Makefile
  • [Linux版本Debian系统]安装cuda 和对应的cudnn以cuda 12.0为例
  • [pyqt5]PyQt5窗体背景图片拉伸填充