手動特徵擷取 II
你正在處理 ANSUR 資料集的變體 height_df,其中每個人的身高量測了 3 次:height_1、height_2、height_3。請在資料集中新增一個「平均身高」特徵,然後刪除原本的 3 個特徵。
本練習屬於課程
Python 的降維
練習說明
- 在資料集中新增一個平均身高特徵。使用
.mean()方法並設定axis=1。 - 從資料集中刪除原本的 3 個身高特徵。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Calculate the mean height
height_df['height'] = height_df[[____]].____
# Drop the 3 original height features
reduced_df = height_df.drop(____, axis=1)
print(reduced_df.head())