We delve into the task of predicting housing prices in Toronto using different models. The dataset used is sourced from the Canada Mortgage and Housing Corporation (CMHC) and covers the housing market data for the last 4 years. Specifically, we focus on apartments and townhouses in Toronto. The average size of Toronto houses is approximately 1600 square feet, which can allow us to analyze the change in rates per square foot.
The housing market data used in this analysis was obtained from the Canada Mortgage and Housing Corporation. You can access the data tables and research reports from their website: CMHC Housing Market Data. https://www.cmhc-schl.gc.ca/en/professionals/housing-markets-data-and-research/housing-data/data-tables/housing-market-data.
To ensure data reliability and accuracy, we consider only the average values of houses sold in new constructions for each month. In cases where insufficient houses were sold or the sale price was confidential, we replace the average value with null. For predictive modeling purposes, we focus on areas with over 40 price values, ensuring a sufficient sample size for robust analysis.
We begin by conducting the Augmented Dickey-Fuller (ADF) test to determine the stationarity of the data. The housing prices in Toronto are found to be stationary, while the prices in Milton are non-stationary. To handle non-stationary data, we apply data transformations, including the use of the logarithmic function, and employ differencing techniques to make the data stationary. We applied various models including ARIMA, SARIMA, and RandomForestRegressor to predict housing prices in Toronto and Milton.
- Unlike many other locations, Toronto does not exhibit a consistent upward trend in real estate pricing across the entire city. Instead, specific areas within Toronto experience notable variations in pricing trends.
- The XGBoost model demonstrated robust performance in predicting housing prices in Toronto, irrespective of the stationarity of the data. Utilizing XGBoost eliminates the need for explicit stationarity checks, simplifying the modeling process.
The mean absolute percentage error (stationary data): 0.0910546488062614
The mean absolute percentage error(non-stationary data): 0.21738003036827325
- The ARIMA time series model consistently outperformed other models for both stationary and non-stationary data, showcasing its effectiveness in capturing and forecasting housing price patterns in Toronto.
- The SARIMA and ARIMA model has the best performance in the case of stationary data (City of Toronto). The absolute mean percentage error is 0.045 and the root mean square error of 94396.
- The Random Forest Regressor gives a lower mean square error but the absolute mean error and root mean square are higher.
- The ARIMA model provides better results in comparison. The root mean square error is 0.097 and the mean absolute percentage error is 1.27
House price prediction using Random Forest Regressor
House Price prediction using XGBoost