離群值

使用 Python 分析 IoT 資料

Matthias Voppichler

IT Developer

離群值

資料集出現離群值的原因:

  • 量測誤差
  • 人為操弄
  • 極端事件
使用 Python 分析 IoT 資料

離群值

temp_mean = data["temperature"].mean() 
temp_std = data["temperature"].std()

data["mean"] = temp_mean
data["upper_limit"] = temp_mean + (temp_std * 3)
data["lower_limit"] = temp_mean - (temp_std * 3) 

print(data.iloc[0]["upper_limit"]) print(data.iloc[0]["mean"]) print(data.iloc[0]["lower_limit"])
29.513933116002725
14.5345
-0.44493311600272456
使用 Python 分析 IoT 資料

離群值圖

data.plot()

以 3 × 標準差計算的平均值與上下界

使用 Python 分析 IoT 資料

自我相關

from statsmodels.graphics import tsaplots

tsaplots.plot_acf(data['temperature'], lags=50)

自我相關圖

使用 Python 分析 IoT 資料

自我相關

from statsmodels.graphics import tsaplots

tsaplots.plot_acf(data['temperature'], lags=50)

自我相關圖,箭頭指向 lag24

使用 Python 分析 IoT 資料

一起來練習吧!

使用 Python 分析 IoT 資料

Preparing Video For Download...