BaşlayınÜcretsiz Başlayın

One-hot encoding and dummy variables

To use categorical variables in a machine learning model, you first need to represent them in a quantitative way. The two most common approaches are to one-hot encode the variables using or to use dummy variables. In this exercise, you will create both types of encoding, and compare the created column sets. We will continue using the same DataFrame from previous lesson loaded as so_survey_df and focusing on its Country column.

Bu egzersiz

Feature Engineering for Machine Learning in Python

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Convert the Country column to a one hot encoded Data Frame
one_hot_encoded = ____(____, ____=['Country'], prefix='OH')

# Print the columns names
print(one_hot_encoded.columns)
Kodu Düzenle ve Çalıştır