Aan de slagGa gratis aan de slag

One hot encoding

In the video, you saw how the 'State' feature can be encoded numerically using the technique of one hot encoding:

ohe_part3.png

Doing this manually would be quite tedious, especially when you have 50 states and over 3000 customers! Fortunately, pandas has a get_dummies() function which automatically applies one hot encoding over the selected feature.

Deze oefening maakt deel uit van de cursus

Marketing Analytics: Predicting Customer Churn in Python

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Import pandas
import pandas as pd

# Perform one hot encoding on 'State'
telco_state = ____.____(____)
Code bewerken en uitvoeren