Plan
The goals of this project are to predict house price and to identify factors that are helpful in predicting the price.
Since the goal is to predict price, this task involves regression modeling. The plan is to implement linear regression and tree-based(random forest and XGBoost) machine learning models to see how they compare.
The dataset was gotten from Algor Bruce on Kaggle. This project was done with Python programming language. Here is the code.
Analyze
The dataset consists of 414 rows and 8 columns and contains no missing values and no duplicates. A column was dropped, the columns were renamed and one column was changed to the appropriate data type.
Summary of the insights after exploring the data:
The price variation between both years is not substantial. The price variation across the number of convenience store is not substantial.
The price increases as the number of convenience stores increases.
There is no linear relationship between house age and house price. Three other variables(distance to the nearest MRT station, latitude and longitude) are related with house price.
Construct and Interpret
Linear Regression Model
The linear regression model was built with statsmodels. The data did not meet most of the model assumptions. The R2 score and the adjusted R2 score for the linear regression model are 58.1% and 57.5% respectively. From the summary table, longitude is not significant in predicting house price.
Tree-based Models
The dataset was split into 80% training set and 20% testing set. The cross-validation technique was used to evaluate the performance of the models. The cross-validation scores for the random forest model outperformed the XGBoost model. The R2 scores of the trained data for the random forest model and XGBoost model are 69.50% and 67.35% respectively.
The test data was used to evaluate the models. The R2 scores of the test data for the random forest model and XGBoost model are 70.89% and 62.17% respectively. The MSE values of the test data for the random forest model and XGBoost model are 41.07 and 46.05 respectively.
Longitude is significant in predicting house price for the tree-based models
The plot below shows that for the random forest model; distance to the nearest MRT station, latitude, house age, longitude, number of convenience store and transaction date in that order are most helpful in predicting house price.
The plot below shows that for the XGBoost model; distance to the nearest MRT station, latitude, house age, longitude, number of convenience store and transaction date in that order are most helpful in predicting house price.
Conclusion
The random forest model outperforms both the linear regression model and the XGBoost model.
A new dataset is needed to get an objective idea of how the random forest model would perform on unseen data.