LoslegenKostenlos loslegen

Encoding categories

You need to help your algorithm understand that you're dealing with categories. You will encode categories of the salary variable, which you know is ordinal based on the values you observed:

  • you first have to tell Python that the salary column is actually categorical
  • you then have to specify the correct order of categories
  • finally, you should encode each category with a numeric value corresponding to its specific position in the order

Diese Übung ist Teil des Kurses

HR Analytics: Predicting Employee Churn in Python

Kurs anzeigen

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Change the type of the "salary" column to categorical
data.salary = data.salary.____('category')
Code bearbeiten und ausführen