iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 14
1
AI & Data

Hands on Data Cleaning and Scraping 資料清理與爬蟲實作系列 第 14

Day14 Feature Engineering, Kurtosis and Skewness 淺談特徵工程、峰度與偏度

特徵工程是把原始資料對應到後續評估分數的轉換過程,是在擬合模型前重要的步驟。常見特徵有:數值型特徵、類別型特徵與時間序列特徵,之後會有文章分別介紹。一般而言,我們取得的資料都會包含類別型(文字型)特徵以及數值型特徵,所以在特徵工程中就會包含進行編碼以及特徵縮放的部分。

Feature engineering is the process of turning raw data into features, it is an essencial step before we fit data to models. There are three types of frequently seen features: numeric features, categorical features, and time series features. We will discuss through them in the following articles. Generally, there will be both numeric features categorical features in our data, so we will have to include at least encoding and feature scaling methods in our feature engineering.
https://ithelp.ithome.com.tw/upload/images/20190915/20119709Z51jKWrQwn.png

編碼方法 Encoding

除了前面文章中提過的編碼方式外,這邊再列出幾種常見的編碼方式。要針對不同的問題類別選擇不同的編碼。

  1. 獨熱編碼
  2. 標籤編碼
  3. 均值編碼
  4. 目標編碼
  5. 頻數編碼
  6. 二值化編碼

Some other mothods of encoding are listed as below. We decide which encoding method to use depend on the problem type.

  1. One-hot encoding
  2. Label encoding
  3. Mean encoding
  4. Target encoding
  5. Count encoding
  6. Label binarize encoding

特徵縮放方法 Feature scaling

歸一化 Scaling to unit length

把原始資料縮放到(0,1)的區間內,統一數據的衡量標準以消除單位的影響。Sklearn中最常用的方法是MinMaxScaler。
Transit raw data into 0-1 range. The most commonly used method in Sklearn is MinMaxScaler.

標準化 Normalization

把資料按比例縮放到一個限定的區間。但如果資料不遵從高斯正態分布時,標準化表現會比較差。常用的標準化方法有Z-score、StandardScaler等。
Normalize data into a specified range. Normalization wouldn't perform so good if the distribution of data is far from normal. Most commonly used methods are z-score normalization, StandardScaler, etc.

偏度 Skewness

資料分布偏斜的方向與程度,分為正態分布(及偏度=0)、右偏分布(正偏分布,偏度>0)、左偏分布(負偏分布,其偏度<0)。
Skewness is a measure of the asymmetry of the probability distribution. Could be either symmetric distribution (skewness=0), positive skew (skewness>0), or negative skew (skewness<0).
https://ithelp.ithome.com.tw/upload/images/20190915/20119709iejOIquDvk.jpg

峰度 Kurtosis

衡量分布的峰態。峰度包括正態分布(峰度值=3),厚尾(峰度值>3),瘦尾(峰度值<3)。
Kurtosis is a descriptor of the shape of a probability distribution.
https://ithelp.ithome.com.tw/upload/images/20190915/20119709w33GySHHJa.jpg

本篇程式碼請參考Github。The code is available on Github.

文中若有錯誤還望不吝指正,感激不盡。
Please let me know if there’s any mistake in this article. Thanks for reading.

Reference 參考資料:

[1] 第二屆機器學習百日馬拉松內容

[2] 偏度(skewness)和峰度(kurtosis)

[3] 特征工程

[4] 特征工程到底是什么?

[5] 一文看懂常用特徵工程方法

[6] 特征工程方法:一、类别变量编码


上一篇
Day13 Converting Continuous Variables into Discrete Values 連續型變數離散化
下一篇
Day15 Numerical Data 1/2 replace N/A or outlier 數值型特徵 1/2 填補N/A與離群值
系列文
Hands on Data Cleaning and Scraping 資料清理與爬蟲實作30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言