use*_*237 7 python machine-learning time-series matplotlib statsmodels
我有一个CSV文件,其中包含近5年的平均温度。使用seasonal_decomposefrom函数分解后statsmodels.tsa.seasonal,得到以下结果。确实,结果没有显示任何季节性!但是,我看到sin趋势很明显!我想知道为什么会这样,我该如何纠正呢?谢谢。
nresult = seasonal_decompose(nseries, model='additive', freq=1)
nresult.plot()
plt.show()
Run Code Online (Sandbox Code Playgroud)
看来您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()
Run Code Online (Sandbox Code Playgroud)
# Redo the same thing, but with the known frequency
seasonal_decompose(df, model='additive', freq=365).plot()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6239 次 |
| 最近记录: |