季節性とトレンド

Python による IoT データの分析

Matthias Voppichler

IT Developer

時系列データの構成要素

  • トレンド
  • 季節性
  • 残差 / ノイズ
series[t] = trend[t] + seasonal[t] + residual[t]
20.2 = 14.9 + 4.39 + 0.91
Python による IoT データの分析

季節分解

import statsmodels.api as sm
# Run seasonal decompose
decomp = sm.tsa.seasonal_decompose(data["temperature"])
print(decomp.seasonal.head())

decomp.plot()
timestamp
2018-10-01 00:00:00   -3.670394
2018-10-01 01:00:00   -3.987451
2018-10-01 02:00:00   -4.372217
2018-10-01 03:00:00   -4.534066
2018-10-01 04:00:00   -4.802165
Freq: H, Name: temperature, dtype: float64
Python による IoT データの分析

季節分解

季節分解プロット

Python による IoT データの分析

統合プロット

# Plot the timeseries
plt.plot(data["temperature"], label="temperature")

decomp = sm.tsa.seasonal_decompose(data["temperature"]) # Plot trend and seasonality plt.plot(decomp.trend, label="trend") plt.plot(decomp.seasonal, label="seasonal") plt.show()
Python による IoT データの分析

統合プロット

季節分解 - 統合プロット

Python による IoT データの分析

練習しましょう!

Python による IoT データの分析

Preparing Video For Download...