Explore Library
Code QuizIntermediate

Target Encoding a City Column

Find the target-encoding step that leaks label information into the model.

Codepython
city_map = df.groupby('city')['churn'].mean()
df['city_enc'] = df['city'].map(city_map)

X_train, X_test, y_train, y_test = train_test_split(
    df[['city_enc']], df['churn'], test_size=0.2)

What is the bug in this code?