開始使用免費開始

檢查高度相關的特徵

現在你要回到 wine 資料集。這個資料集包含連續的數值型特徵。請對資料集計算 Pearson 相關係數,以判斷哪些欄位適合被移除。接著,把那些欄位從 DataFrame 中刪除。

本練習屬於課程

Python 的 Machine Learning 前處理

檢視課程

練習說明

  • 列印 wine 資料集中每對特徵的 Pearson 相關係數。
  • wine 中刪除與「至少另外 2 個欄位」的相關係數「大於 0.75」的任何欄位。

動手互動練習

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

# Print out the column correlations of the wine dataset
print(____)

# Drop that column from the DataFrame
wine = wine.____(____, ____)

print(wine.head())
編輯並執行程式碼