在 Python 中进行对数归一化
既然我们已经知道 wine 数据集中的 Proline 列方差很大,就对它做一次对数归一化吧。
numpy 已作为 np 导入。
本练习是课程的一部分
Python 中的机器学习预处理
练习说明
- 为对比,先打印
Proline列的方差。 - 使用
np.log()作用于Proline列,创建一个新的对数归一化列,命名为Proline_log。 - 打印
Proline_log列的方差,看看有何变化。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Print out the variance of the Proline column
print(____)
# Apply the log normalization function to the Proline column
wine[____] = np.____(____)
# Check the variance of the normalized Proline column
print(____)