数据分布与变换

用 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 练习机器学习面试题

¡Vamos a practicar!

用 Python 练习机器学习面试题

Preparing Video For Download...