การเติมค่าที่หายไปในคอลัมน์ต่อเนื่อง

Feature Engineering สำหรับ Machine Learning ใน Python

Robert O'Callaghan

Director of Data Science, Ordergroove

การลบค่าที่หายไป

  • ไม่สามารถลบแถวที่มีค่าหายไปในชุดข้อมูลทดสอบได้
Feature Engineering สำหรับ Machine Learning ใน Python

มีทางเลือกอื่นอีกไหม?

  • คอลัมน์ประเภท Categorical: แทนที่ค่าที่หายไปด้วยค่าที่พบบ่อยที่สุด หรือใช้ string เพื่อระบุว่าค่าหายไป เช่น 'None'
  • คอลัมน์ตัวเลข: แทนที่ค่าที่หายไปด้วยค่าที่เหมาะสม
Feature Engineering สำหรับ Machine Learning ใน Python

การวัดแนวโน้มเข้าสู่ส่วนกลาง

  • ค่าเฉลี่ย
  • มัธยฐาน
Feature Engineering สำหรับ Machine Learning ใน Python

คำนวณการวัดแนวโน้มเข้าสู่ส่วนกลาง

print(df['ConvertedSalary'].mean())
print(df['ConvertedSalary'].median())
92565.16992481203
55562.0
Feature Engineering สำหรับ Machine Learning ใน Python

เติมค่าที่หายไป

df['ConvertedSalary'] = df['ConvertedSalary'].fillna(
    df['ConvertedSalary'].mean()
)
df['ConvertedSalary'] = df['ConvertedSalary']\
                         .astype('int64')
Feature Engineering สำหรับ Machine Learning ใน Python

การปัดเศษค่า

df['ConvertedSalary'] = df['ConvertedSalary'].fillna(
    round(df['ConvertedSalary'].mean())
)
Feature Engineering สำหรับ Machine Learning ใน Python

มาฝึกกันเถอะ!

Feature Engineering สำหรับ Machine Learning ใน Python

Preparing Video For Download...