作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个 CSV 文件,其中包含将近 5 年的平均温度。使用 statsmodels.tsa.seasonal
中的 seasonal_decompose
函数进行分解后,我得到了以下结果。事实上,结果不显示任何季节性!但是,我在趋势中看到了明显的错误
!我想知道为什么会这样,我该如何纠正它?谢谢。
nresult = seasonal_decompose(nseries, model='additive', freq=1)
nresult.plot()
plt.show()
最佳答案
您的 freq
似乎已关闭。
import numpy as np
import pandas as pd
from statsmodels.tsa.seasonal import seasonal_decompose
# Generate some data
np.random.seed(0)
n = 1500
dates = np.array('2005-01-01', dtype=np.datetime64) + np.arange(n)
data = 12*np.sin(2*np.pi*np.arange(n)/365) + np.random.normal(12, 2, 1500)
df = pd.DataFrame({'data': data}, index=dates)
# Reproduce the example in OP
seasonal_decompose(df, model='additive', freq=1).plot()
# Redo the same thing, but with the known frequency
seasonal_decompose(df, model='additive', freq=365).plot()
关于python - python中的季节性分解,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47609537/
我是一名优秀的程序员,十分优秀!