Canadian-dollar_RMB

Posted githung-zeng

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Canadian-dollar_RMB相关的知识,希望对你有一定的参考价值。

import pandas as pd
import matplotlib.pyplot as plt
import statsmodels as sm
from statsmodels.graphics.tsaplots import plot_acf,plot_pacf
import numpy as np
discfile = r‘C:UsersGitHung ZengDocumentsWeChat FilesWT13662535567Files日线数据Canadian-dollar_RMB.xlsx‘
forecastnum = 5
data = pd.read_excel(discfile, index_col = ‘时间‘)
data = data[‘收‘]
plt.rcParams[‘font.sans-serif‘] = [‘SimHei‘]
##datetime时间转化
data.index = pd.to_datetime(data.index,format="%Y/%m/%d")
plt.figure(figsize=(8,4))
plt.plot(data)
plt.show()
##ACF,PACF计算
fig = plt.figure(figsize = (12,8))

ax1 = fig.add_subplot(211)
fig = plot_acf(data,lags = 40,ax =ax1)
ax1.xaxis.set_ticks_position(‘bottom‘)
fig.tight_layout()

ax2 = fig.add_subplot(212)
fig = plot_pacf(data,lags = 40,ax =ax2)
ax1.xaxis.set_ticks_position(‘bottom‘)
fig.tight_layout()
data_diff = data.diff(5)
data_diff = data_diff.dropna()

##ACF,PACF计算
fig = plt.figure(figsize = (12,8))

ax1 = fig.add_subplot(211)
fig = plot_acf(data_diff,lags = 40,ax =ax1)
ax1.xaxis.set_ticks_position(‘bottom‘)
fig.tight_layout()

ax2 = fig.add_subplot(212)
fig = plot_pacf(data_diff,lags = 40,ax =ax2)
ax1.xaxis.set_ticks_position(‘bottom‘)
fig.tight_layout()

arima11 = sm.tsa.arima_model.ARMA(data_diff,order=(6,4))
model_results=arima11.fit()

predict = model_results.predict()
forecast = model_results.forecast(5)
plt.figure(figsize=(12,8))
plt.plot(data_diff.iloc[data_diff.size-1000:data_diff.size])
plt.plot(predict[data_diff.size-1000:data_diff.size],‘r‘)
plt.show()

forecast[1]

以上是关于Canadian-dollar_RMB的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数