找出需要標準化的特徵
在這個練習中,你要檢視 UFO 資料集各欄位的變異數,判斷哪些特徵需要標準化。先看看 seconds 與 minutes 兩個欄位的變異數,你會發現 seconds 的變異數非常高。由於 seconds 與 minutes 彼此相關(在之後進行模型特徵選擇時會處理這個問題),我們先對 seconds 欄位做對數正規化。
本練習屬於課程
Python 的 Machine Learning 前處理
練習說明
- 計算
seconds與minutes欄位的變異數,並仔細查看結果。 - 對
seconds欄位執行對數正規化,轉換成名為seconds_log的新欄位。 - 列印
seconds_log欄位的變異數。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Check the variance of the seconds and minutes columns
print(____)
# Log normalize the seconds column
ufo["seconds_log"] = ____
# Print out the variance of just the seconds_log column
print(____)