YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
House Price Prediction and Classification Models
Assignment #2 โ Machine Learning
This repository contains my full solution for Assignment #2.
The project includes a complete machine learning pipeline with data cleaning, exploratory data analysis, feature engineering, clustering, regression models, classification models, evaluation, and model deployment.
video link - https://share.descript.com/view/aKOwykkMSex
Repository link:
https://huggingface.co/omerbasik1/house-price-model/tree/main
Dataset Overview
The dataset contains approximately 316,000 real estate listings.
It includes both numeric and categorical features such as:
- Apartment area (square meters)
- Number of rooms and bathrooms
- Floor and building type
- Geographic location (longitude, latitude, district)
- Building age and renovation condition
- Market-related features such as DOM, followers and community average price
The main goals of the project are:
- Regression โ predicting apartment prices.
- Classification โ transforming the price into categories and predicting whether a property is cheap or expensive.
Data Cleaning and Exploratory Data Analysis (EDA)
The data was cleaned and prepared before modeling.
The main cleaning steps included:
- Removing duplicate rows
- Converting text-based columns to numeric form
- Handling missing values using median (for numeric) and "Unknown" (for categorical)
- Filtering extreme outliers such as unrealistic apartment sizes and extreme prices
During the EDA stage, multiple visualizations were created to understand the structure of the data:
- Histograms were used to examine the distribution of apartment prices.
- Scatter plots showed the clear relationship between apartment size and price.
- Bar charts were used to compare average prices across districts.
- A correlation heatmap was used to identify the strongest relationships between numerical features and price.
Key findings from the EDA:
- Apartment size has the strongest correlation with price.
- District and location significantly affect average price levels.
- Renovation condition, elevator availability, and subway proximity also have a noticeable impact.
Baseline Regression Model
A baseline Linear Regression model was trained using the cleaned dataset.
The data was split into training and testing sets, and numeric features were scaled before training.
Evaluation metrics included:
- Mean Absolute Error (MAE)
- Root Mean Squared Error (RMSE)
- Rยฒ score
The baseline model achieved moderate performance and was mainly used as a reference point for measuring the impact of feature engineering and more advanced models.
Feature Engineering and Clustering
To improve model performance, several feature engineering techniques were applied.
New engineered features:
- Price per square meter
- Total number of rooms
- Building age
Polynomial and interaction features:
- Square of the apartment area
- Square of building age
- Square of total rooms
- Interactions such as area multiplied by building age
Clustering:
K-Means clustering was applied to group similar apartments based on key features such as area, price per square meter, building age and room count.
From this process, additional features were created:
- Cluster group assignment
- Distance from the cluster centroid
- Distance to each cluster
A unified preprocessing pipeline was built using:
- One-Hot Encoding for categorical features
- Standard Scaling for numeric features
This ensured consistent preprocessing without data leakage.
Improved Regression Models and Results
Three regression models were trained and evaluated using the engineered dataset:
- Linear Regression
- Gradient Boosting Regressor
- Random Forest Regressor
The Random Forest model achieved the best performance with the lowest RMSE and the highest Rยฒ score.
Therefore, it was selected as the final regression model and exported as:
winning_model.pkl
Regression to Classification
The regression problem was converted into a binary classification problem using a median split on apartment prices:
- Class 0: apartments priced below the median
- Class 1: apartments priced at or above the median
The class distribution remained balanced, allowing stable training of classification models.
Three classifiers were trained:
- Logistic Regression
- Random Forest Classifier
- Gradient Boosting Classifier
The models were evaluated using:
- Precision
- Recall
- F1 score
- Confusion matrices
The Gradient Boosting classifier achieved the best classification performance and was selected as the final classification model.
It was exported as:
best_classifier.pkl
Repository Files
The repository contains the following key files:
- winning_model.pkl โ final regression model
- best_classifier.pkl โ final classification model
- assignment2_notebook.ipynb โ notebook with full code
- presentation_video.mp4 โ presentation recording
- README.md โ this documentation
Final Summary
This project demonstrates a full machine learning workflow: data cleaning, exploratory analysis, feature engineering, clustering, regression modeling, classification modeling, evaluation, and deployment.
Both the regression and classification models were exported and uploaded to the HuggingFace repository so they can be reused for future predictions.
Author: Omer Basik
Course: Machine Learning โ Assignment #2














