# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# + [markdown] id="xuggRSThLRon"
# ## LabelEncoder

# + id="aBktcQb-nv29"
cities = ['London', 'Berlin', 'Berlin', 'New York', 'London']

from sklearn.preprocessing import LabelEncoder

encoder = LabelEncoder()
city_labels = encoder.fit_transform(cities)

city_labels
# -

# ## OneHotEncoder

# + id="LAwpjiOVqX0Q"
from sklearn.preprocessing import OneHotEncoder

one_hot_encoder = OneHotEncoder(sparse=False)
city_labels = city_labels.reshape((5, 1))
one_hot_encoder.fit_transform(city_labels)

StarcoderdataJupyterScriptsDedupFiltered