时间序列分析与无监督学习方法详解
在数据分析和机器学习领域,时间序列分析和无监督学习是两个重要的方向。时间序列分析常被用于预测未来值,而无监督学习则有助于发现数据中的潜在结构。下面将详细介绍相关的方法和技术。
1. 自相关检验与ARIMA模型构建
1.1 自相关检验
在对时间序列进行分析时,首先要确定对数时间序列至少需要进行一阶差分才能达到平稳。接下来,我们绘制一阶对数序列的自相关函数(ACF)和偏自相关函数(PACF)图。
import matplotlib.pyplot as plt
import statsmodels.api as sm
import numpy as np
from sklearn.metrics import mean_absolute_error, mean_squared_error
# 假设ts_log_diff是一阶对数差分后的时间序列
fig, (ax1, ax2) = plt.subplots(1, 2, figsize = (10,3))
# ACF chart
fig = sm.graphics.tsa.plot_acf(ts_log_diff.values.squeeze(), lags=20, ax=ax1)
# draw 95% confidence interval line
ax1.axhline(y=-1.96/np.sqrt(len(ts_log_diff)),linestyle='--',color='gray')
ax1.axhline(y=1.96/np.sqrt(len(ts_log_diff)),linestyle='--',
超级会员免费看
订阅专栏 解锁全文
1279

被折叠的 条评论
为什么被折叠?



