開始使用免費開始

在 Python 中進行對數正規化

既然我們已經知道 wine 資料集中的 Proline 欄位變異很大,來對它做對數正規化吧。

numpy 已匯入為 np

本練習屬於課程

Python 的 Machine Learning 前處理

檢視課程

練習說明

  • 先列印 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(____)
編輯並執行程式碼