Điền giá trị liên tục bị thiếu

Feature Engineering cho Machine Learning bằng Python

Robert O'Callaghan

Director of Data Science, Ordergroove

Xóa giá trị thiếu

  • Không thể xóa các hàng có giá trị thiếu trong tập kiểm tra
Feature Engineering cho Machine Learning bằng Python

Có thể làm gì khác?

  • Cột phân loại: Thay giá trị thiếu bằng giá trị xuất hiện nhiều nhất hoặc chuỗi đánh dấu thiếu như 'None'
  • Cột số: Thay giá trị thiếu bằng giá trị phù hợp
Feature Engineering cho Machine Learning bằng Python

Các thước đo khuynh hướng trung tâm

  • Trung bình
  • Trung vị
Feature Engineering cho Machine Learning bằng Python

Tính các thước đo khuynh hướng trung tâm

print(df['ConvertedSalary'].mean())
print(df['ConvertedSalary'].median())
92565.16992481203
55562.0
Feature Engineering cho Machine Learning bằng Python

Điền giá trị thiếu

df['ConvertedSalary'] = df['ConvertedSalary'].fillna(
    df['ConvertedSalary'].mean()
)
df['ConvertedSalary'] = df['ConvertedSalary']\
                         .astype('int64')
Feature Engineering cho Machine Learning bằng Python

Làm tròn giá trị

df['ConvertedSalary'] = df['ConvertedSalary'].fillna(
    round(df['ConvertedSalary'].mean())
)
Feature Engineering cho Machine Learning bằng Python

Ayo berlatih!

Feature Engineering cho Machine Learning bằng Python

Preparing Video For Download...