開始使用免費開始

平方根轉換

在影片中你學到,對數函式可以用來壓平數值之間的差異。對數函式的另一個替代方案是平方根:這個函式同樣會壓平數值差異,但效果稍弱一些。

這裡提供一個很小的 basetable,包含 4 位捐款人的母體,以及一個預測變數「donations」,代表去年捐款總額。在本練習中,你將把對數轉換和平方根轉換加入這個 basetable,並比較兩種轉換的效果。

本練習屬於課程

Python 中級預測分析

檢視課程

練習說明

  • 將變數「donations」的對數轉換加入 basetable
  • 將變數「donations」的平方根轉換加入 basetable
  • 印出加入這些特徵後的 basetable。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Add the log transformation of the variable "donations"
basetable["donations_log"] = ____.____(____["____"])

# Add the square root transformation of the variable "donations"
basetable["donations_sqrt"] = ____.____(____["____"])

# Compare the transformations
___
編輯並執行程式碼