Demonstrates three categorical encoding techniques on the Ames Housing dataset, each applied to a column chosen because it fits that method best.
| Technique | Column | Why this column |
|---|---|---|
| Label Encoding | Kitchen Qual |
Ordinal — natural rank order (Poor < Fair < Typical/Average < Good < Excellent) |
| One-Hot Encoding | Bldg Type |
Nominal, low cardinality (5 categories, no order) |
| Frequency Encoding | Neighborhood |
Nominal, high cardinality (28 categories) — one-hot would create too many sparse columns |
Ames_Housing_Encodings.ipynb— full notebook: data inspection, all three encodings (each in its own dataframe copy with validation checks), pre-/post-encoding visualizations, and a correlation matrix againstSalePriceAmesHousing.csv— dataset used
- Setup & load data
- Inspect target columns for missing values
- Label encoding —
Kitchen Qual - One-hot encoding —
Bldg Type - Frequency encoding —
Neighborhood - Summary table
- Visualizations — pre-encoding distributions, post-encoding distributions, correlation matrix
Kitchen Qual_Label correlates strongly with SalePrice (r ≈ 0.67) — kitchen quality is a meaningful price driver in this dataset. The one-hot Bldg Type columns show negative correlation with each other, which is expected: the categories are mutually exclusive by construction.
pandas
scikit-learn
matplotlib
seaborn
jupyter notebook Ames_Housing_Encodings.ipynb