為何要處理遺漏值?

在 Python 中處理遺漏值

Suraj Donthi

Deep Learning & Computer Vision Consultant

為什麼會有遺漏值?

  • 真實世界的資料很雜亂

你知道嗎?有 72% 的組織認為資料品質問題會削弱顧客信任與觀感。

1 [Top 9 Benefits of Data Cleansing for Businesses](https://bit.ly/2QwMrab)
在 Python 中處理遺漏值

為什麼會有遺漏值?

  • 資料蒐集過程遺漏
    • 天氣分析時的感測器故障
    • 醫療診斷的病患資料不完整等
  • 不小心刪除
    • 資料遺失
    • 人為誤刪
在 Python 中處理遺漏值

本課程你將學到

  • 處理遺漏值的重要性
  • 在雜亂資料中偵測遺漏值
  • 分析遺漏型態
  • 針對下列情境妥善處理遺漏值
    • 數值型
    • 時間序列
    • 類別值
在 Python 中處理遺漏值

本課程你將學到

  • 用簡單技術填補(取代)遺漏值
  • 用進階技術填補遺漏值
  • 最後評估處理遺漏值的最佳方法
在 Python 中處理遺漏值

處理遺漏值的工作流程

  1. 將所有遺漏值統一為 null。
  2. 分析資料中遺漏的程度與型態。
  3. 適當刪除或填補遺漏值。
  4. 評估並比較處理/填補後資料集的效能。
在 Python 中處理遺漏值

NULL 值運算

None

None or True # Same for False
True
None + True # For all operators
TypeError: unsupported operand
None / 3 # For all operators
TypeError: unsupported operand
type(None)
NoneType

np.nan

import numpy as np
np.nan or True  # Same for False
nan
np.nan * True # For all operators
nan
np.nan - 3 # For all operators
nan
type(np.nan)
float
在 Python 中處理遺漏值

NULL 值運算

None

None == None
True
np.isnan(None)
False

np.nan

np.nan == np.nan
False
np.isnan(np.nan)
True
在 Python 中處理遺漏值

一起來練習吧!

在 Python 中處理遺漏值

Preparing Video For Download...