Vyplnění chybějících hodnot pro spojité proměnné

Feature Engineering for Machine Learning in Python

Robert O'Callaghan

Director of Data Science, Ordergroove

Odstranění chybějících hodnot

  • Řádky s chybějícími hodnotami v testovací sadě nelze odstranit
Feature Engineering for Machine Learning in Python

Jaké jsou další možnosti?

  • Kategorické sloupce: Nahraďte chybějící hodnoty nejčastěji se vyskytující hodnotou nebo řetězcem označujícím chybění, např. 'None'
  • Numerické sloupce: Nahraďte chybějící hodnoty vhodnou hodnotou
Feature Engineering for Machine Learning in Python

Míry centrální tendence

  • Průměr
  • Medián
Feature Engineering for Machine Learning in Python

Výpočet měr centrální tendence

print(df['ConvertedSalary'].mean())
print(df['ConvertedSalary'].median())
92565.16992481203
55562.0
Feature Engineering for Machine Learning in Python

Vyplnění chybějících hodnot

df['ConvertedSalary'] = df['ConvertedSalary'].fillna(
    df['ConvertedSalary'].mean()
)
df['ConvertedSalary'] = df['ConvertedSalary']\
                         .astype('int64')
Feature Engineering for Machine Learning in Python

Zaokrouhlení hodnot

df['ConvertedSalary'] = df['ConvertedSalary'].fillna(
    round(df['ConvertedSalary'].mean())
)
Feature Engineering for Machine Learning in Python

Pojďme si procvičit!

Feature Engineering for Machine Learning in Python

Preparing Video For Download...