Views
No views yet
history_price (regression) and whether it is expensive vs not-expensive (classification) from the London House Price Data Kaggle dataset.jakewright/house-price-data. The full file has 418,201 rows × 28 columns, but a random sample of 30,000 rows is used to keep the analysis manageable. The numeric target is history_price — the historical sale price of a property in GBP. The pipeline starts with EDA (cleaning, outlier detection, descriptive statistics, four research questions), trains a baseline LinearRegression on six numeric features, adds a feature-engineering step (one-hot encoding of propertyType), runs K-Means with k = 3 on the property features and adds a cluster_id feature, then trains three improved regression models (Linear / Random Forest / Decision Tree). The Random Forest is the regression winner and is exported as a pickle. The continuous target is then converted into a binary class using a median split (expensive vs not-expensive), and three classifiers are trained (Logistic Regression / Random Forest / Decision Tree) with full classification reports and confusion-matrix evaluation.history_price) acting as the target — leaving 27 input features. To keep the analysis manageable a random sample of 30,000 rows is taken at the start of EDA, comfortably above the 10K-row / 15-feature minimums required by the assignment. The feature mix is rich and includes geographic information (latitude, longitude, postcode, outcode, country), property characteristics (floorAreaSqM, bedrooms, bathrooms, livingRooms, propertyType, currentEnergyRating), and sale-related fields (saleEstimate_lowerPrice, saleEstimate_upperPrice, saleEstimate_confidenceLevel, history_date, history_price).datetime, drops constant columns, and inspects missing values per column. Outliers are flagged with the IQR rule and visualised as boxplots — the most extreme values in history_price, floorAreaSqM, and number of rooms are kept because they are legitimate luxury / large-property cases rather than data-entry errors.

| # | Question | Finding |
|---|---|---|
| 1 | What is the distribution of history_price? | Heavy right-skew, with a long high-end tail and most properties below £500K |
| 2 | How does floor area affect price? | Clear positive trend — bigger floor area ⇒ higher price, with growing variance |
| 3 | How does the number of bathrooms affect price? | More bathrooms ⇒ higher price, especially noticeable for 2+ bathrooms |
| 4 | How does property type affect price? | Detached houses dominate the high-price end; flats cluster at the low end |




LinearRegression is trained on six numeric features — floorAreaSqM, bedrooms, bathrooms, livingRooms, latitude, longitude — using an 80/20 train-test split with random_state=42. After dropping rows with missing values, the modelling dataset has 22,825 rows. The baseline achieves an MAE of about £290,373 and an R² of about 0.39 — meaning the model explains roughly 39% of the variance in historical prices and is off by about £290K on average. This is a useful starting point but the error is large because property prices depend on many factors beyond the six inputs.propertyType — a useful nominal categorical that the EDA flagged as price-relevant. The expanded feature matrix has 24 columns and 22,825 rows. A second LinearRegression is fit on this richer matrix and reaches MAE ≈ £291,661 and R² ≈ 0.397 — a small bump in R² over the baseline, confirming that property type carries some independent signal even though the linear model cannot fully exploit it.
cluster_id) is then merged back into the modelling matrix as an additional feature. Re-training the linear model with cluster_id included gives MAE ≈ £290,075 and R² ≈ 0.395 — a marginal but real improvement over the baseline, showing that the cluster signal adds a small amount of complementary information.floorAreaSqM, latitude, and longitude as the dominant predictors:
winning_regression_model.pkl via Python pickle for reuse.


winning_classification_model.pkl to the same HuggingFace Model Repository as the regression pickle.winning_regression_model.pkl is the exported Random Forest Regressor that predicts history_price. winning_classification_model.pkl is the exported Random Forest Classifier that predicts the expensive / not-expensive label. The full notebook with all 10 parts and section-by-section findings is included as Copy_of_Assignment_2_Classification,_Regression,_Clustering,_Evaluation.ipynb. The source dataset is fetched from Kaggle (jakewright/house-price-data) using kagglehub. README.md is this file.