开始使用免费开始使用

在 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(____)
编辑并运行代码