資料分佈與轉換

用 Python 練習機器學習面試題

Lisa Stuart

Data Scientist

不同的分佈

資料分佈

1 https://www.researchgate.net/figure/Bias-Training-and-test-data-sets-are-drawn-from-different-distributions_fig22_330485084
用 Python 練習機器學習面試題

訓練/測試切分

train, test = train_test_split(X, y, test_size=0.3)

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)

sns.pairplot() --> 分佈與散佈圖矩陣

用 Python 練習機器學習面試題

資料轉換

資料轉換

1 https://www.researchgate.net/figure/Example-of-the-effect-of-a-log-transformation-on-the-distribution-of-the-dataset_fig20_308007227
用 Python 練習機器學習面試題
Box-Cox 轉換

scipy.stats.boxcox(data, lmbda= )

lmbda (p) $x^p$ 轉換
-2 $x^{-2} = 1/2$ 倒數平方
-1 $x^{-1} = 1/x$ 倒數
-0.5 $x^{-1/2} = 1/\sqrt{x}$ 倒數平方根
0.0 $\log{(x)}$ 對數
0.5 $x^{1/2} = \sqrt{x}$ 平方根
1 $x^1 = x$ 不轉換
2 $x^2 = x$ 平方
用 Python 練習機器學習面試題

一起來練習吧!

用 Python 練習機器學習面試題

Preparing Video For Download...