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

Creating a dummy from a two-category variable

Given is a basetable with one predictive variable "gender". Make sure that "gender" can be used as a predictive variable in a logistic regression model by creating dummy variables for it.

Bu egzersiz

Intermediate Predictive Analytics in Python

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

Egzersiz talimatları

  • Create a pandas dataframe dummies_gender that has the dummy variables for "gender". Make sure to avoid multicollinearity.
  • Add these dummies to the original basetable.
  • Remove the original variable "gender" from the basetable.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Create the dummy variable
dummies_gender = pd.____(____["____"], drop_first=____)

# Add the dummy variable to the basetable
basetable = pd.concat([____, ____], axis=1)

# Delete the original variable from the basetable
del basetable["____"]
print(basetable.head())
Kodu Düzenle ve Çalıştır