Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Label Encoding of the Target Variable | Processing Categorical Data
Data Preprocessing
course content

Зміст курсу

Data Preprocessing

Data Preprocessing

1. Brief Introduction
2. Processing Quantitative Data
3. Processing Categorical Data
4. Time Series Data Processing
5. Feature Engineering
6. Moving on to Tasks

Label Encoding of the Target Variable

Let's go straight to the main thing - label encoding implements everything the same as ordinal encoder, but:

  • Methods work with different data dimensions;
  • The order of the categories is not important for label encoding.

How to use this method in Python:

1234567891011121314
from sklearn.preprocessing import LabelEncoder import pandas as pd # Simple categorical variable fruits = pd.Series(['apple', 'orange', 'banana', 'banana', 'apple', 'orange', 'banana']) # Create label encoder object le = LabelEncoder() # Fit and transform the categorical variable using label encoding fruits_encoded = le.fit_transform(fruits) # Print the encoded values print(fruits_encoded)
copy

Завдання

Read the dataset 'salary_and_gender.csv' and encode the output column 'Gender' with label encoding.

Завдання

Read the dataset 'salary_and_gender.csv' and encode the output column 'Gender' with label encoding.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 3. Розділ 4
toggle bottom row

Label Encoding of the Target Variable

Let's go straight to the main thing - label encoding implements everything the same as ordinal encoder, but:

  • Methods work with different data dimensions;
  • The order of the categories is not important for label encoding.

How to use this method in Python:

1234567891011121314
from sklearn.preprocessing import LabelEncoder import pandas as pd # Simple categorical variable fruits = pd.Series(['apple', 'orange', 'banana', 'banana', 'apple', 'orange', 'banana']) # Create label encoder object le = LabelEncoder() # Fit and transform the categorical variable using label encoding fruits_encoded = le.fit_transform(fruits) # Print the encoded values print(fruits_encoded)
copy

Завдання

Read the dataset 'salary_and_gender.csv' and encode the output column 'Gender' with label encoding.

Завдання

Read the dataset 'salary_and_gender.csv' and encode the output column 'Gender' with label encoding.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 3. Розділ 4
toggle bottom row

Label Encoding of the Target Variable

Let's go straight to the main thing - label encoding implements everything the same as ordinal encoder, but:

  • Methods work with different data dimensions;
  • The order of the categories is not important for label encoding.

How to use this method in Python:

1234567891011121314
from sklearn.preprocessing import LabelEncoder import pandas as pd # Simple categorical variable fruits = pd.Series(['apple', 'orange', 'banana', 'banana', 'apple', 'orange', 'banana']) # Create label encoder object le = LabelEncoder() # Fit and transform the categorical variable using label encoding fruits_encoded = le.fit_transform(fruits) # Print the encoded values print(fruits_encoded)
copy

Завдання

Read the dataset 'salary_and_gender.csv' and encode the output column 'Gender' with label encoding.

Завдання

Read the dataset 'salary_and_gender.csv' and encode the output column 'Gender' with label encoding.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Let's go straight to the main thing - label encoding implements everything the same as ordinal encoder, but:

  • Methods work with different data dimensions;
  • The order of the categories is not important for label encoding.

How to use this method in Python:

1234567891011121314
from sklearn.preprocessing import LabelEncoder import pandas as pd # Simple categorical variable fruits = pd.Series(['apple', 'orange', 'banana', 'banana', 'apple', 'orange', 'banana']) # Create label encoder object le = LabelEncoder() # Fit and transform the categorical variable using label encoding fruits_encoded = le.fit_transform(fruits) # Print the encoded values print(fruits_encoded)
copy

Завдання

Read the dataset 'salary_and_gender.csv' and encode the output column 'Gender' with label encoding.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 3. Розділ 4
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt