Datawhale干货
(相关资料图)
作者:戳戳龍,上海交通大学,量化算法工程师
前言? 平时工作中每天都在和时间序列打交道,对时间序列分析进行研究是有必要的
? 分享和交流一些自己的在时序处理方面的心得,提供一些思路
? 介绍时序的发展情况,以及目前业界常用的方法
? 代码希望能模板化,能直接复制过去使用
时序方法发展趋势?series = trend + seasons + dependence+ error
? 时间序列的趋势分量表示该序列均值的持续的、长期的变化
Df["ma20"] = Df["amt"].rolling(20).mean()周期性(季节性)季节时序图
def plot_season(Df): df = Df.copy() # 计算每周属于哪一年 df["year"] = df["date"].dt.year # 计算每周为一年当中的第几周 df["week_of_year"] = df["date"].dt.weekofyear for year in df["year"].unique(): tmp_df = df[df["year"] == year] plt.plot(tmp_df["week_of_year"], tmp_df["amt"], ".-", label=str(year)) plt.legend() plt.show()周期判断
?如果每隔h个单位,ACF值有一个局部高峰,则数据存在以h为单位的周期性
from statsmodels.graphics.tsaplots import plot_acfplot_acf(Df["amt"], lags=500).show()自相关性自相关
?自相关函数 autocorrelation function有序的随机变量序列与其自身相比较自相关函数反映了同一序列在不同时序的取值之间的相关性
X 关闭
Copyright © 2015-2022 人人机械网版权所有 备案号:粤ICP备18023326号-36 联系邮箱:8557298@qq.com