scieee AI-readable full text Open interactive document viewer

Forecasting models for real estate market analysis The case study of Portugal

Coutinho, Ana Lúcia Barata

Abstract

The real estate market is known for its difficulties and volatility, particularly in determining property values, which significantly impact economic choices and societal well-being. Accurate predictions of property prices can facilitate informed decision-making and influence investment strategies and market dynamics. This study focuses on predicting property prices in Portugal and looks at different regions with a focus on Lisbon. It attempts to use innovative methods such as Decision Tree, Random Forest, Artificial Neural Networks, Linear Regression, and K-Nearest Neighbors. The research provides an in-depth evaluation of forecasting techniques by analyzing historical data and employing various machine learning algorithms. The models are specifically designed to understand the complex dynamics of different property types in different regions of Portugal. Overall, the Random Forest model is the best model for predicting property prices, followed by Decision Tree model. This forecast is also important because it provides us with an insight into the importance of certain features in real estate property prices. Using advanced predictive models does not only enhance the understanding of real estate market trends but also enables stakeholders to make informed decisions.

Full text

Master Degree Program in Information Management Forecasting models for real estate market analysis The case study of Portugal Ana Lúcia Barata Coutinho Project Work presented as partial requirement for obtaining the Master Degree Program in Information Management NOVA Information Management School Instituto Superior de Estatística e Gestão de Informação Universidade Nova de Lisboa MGI NOVA Information Management School Instituto Superior de Estatística e Gestão de Informação Universidade Nova de Lisboa FORECASTING MODELS FOR REAL ESTATE MARKET ANALYSIS THE CASE STUDY OF PORTUGAL By Ana Lúcia Barata Coutinho Project Work presented as partial requirement for obtaining the Master’s degree in Information Management, with a specialization in Knowledge Management and Business Intelligence Supervisor(s): João Bruno Morais de Sousa Jardim Miguel de Castro Simões Ferreira Neto November 2023 ii STATEMENT OF INTEGRITY I hereby declare having conducted this academic work with integrity. I confirm that I have not used plagiarism or any form of undue use of information or falsification of results along the process leading to its elaboration. I further declare that I have fully acknowledge the Rules of Conduct and Code of Honor from the NOVA Information Management School. [Ana Lúcia Barata Coutinho] [Lisbon, November 22nd, 2023] iii ACKNOWLEDGEMENTS This research would not have been possible without the incredible support of countless people who guided me through the process, shared their knowledge and answered all of my questions. I would like to thank my family for believing in me and it was because of their emotional support that they kept my motivation high throughout the project. Thanks to my friends and data scientists who provided advice and feedback on the many challenges I had to overcome. I am especially thankful to my two co-supervisors Miguel de Castro Neto and João Bruno Jardim and NOVA IMS for providing materials and support in the essential context that helped enrich my knowledge and this research. iv ABSTRACT The real estate market is known for its difficulties and volatility, particularly in determining property values, which significantly impact economic choices and societal well-being. Accurate predictions of property prices can facilitate informed decision-making and influence investment strategies and market dynamics. This study focuses on predicting property prices in Portugal and looks at different regions with a focus on Lisbon. It attempts to use innovative methods such as Decision Tree, Random Forest, Artificial Neural Networks, Linear Regression, and K-Nearest Neighbors. The research provides an in-depth evaluation of forecasting techniques by analyzing historical data and employing various machine learning algorithms. The models are specifically designed to understand the complex dynamics of different property types in different regions of Portugal. Overall, the Random Forest model is the best model for predicting property prices, followed by Decision Tree model. This forecast is also important because it provides us with an insight into the importance of certain features in real estate property prices. Using advanced predictive models does not only enhance the understanding of real estate market trends but also enables stakeholders to make informed decisions. KEYWORDS Real Estate, Real Estate Property Prices, Machine Learning, Random Forest, Artificial Neural Network, K-Nearest Neighbors, Decision Tree. Sustainable Development Goals (SGD): The study is aligned with Sustainable Development Goal 9: Industry, Innovation, and Infrastructure, employing innovative methods such as Decision Tree, Random Forest, Artificial Neural Network, Linear Regression, and K-Nearest Neighbors. More specifically, this thesis aims to produce knowledge to the technological advancement of the real estate field, by integrating real estate data to understand and forecast price dynamics. In such a complex and crucial domain, this research thus provides one more contribution to understand the real estate property market prices and addressing its current challenges. v INDEX 1. Introduction .................................................................................................................. 1 2. Literature review .......................................................................................................... 3 2.1. Macroeconomic ..................................................................................................... 3 2.1.1. Bubbles ........................................................................................................... 4 2.1.2. Tourism ........................................................................................................... 5 2.1.3. Crime .............................................................................................................. 5 2.2. Price Forecast ........................................................................................................ 6 2.2.1. Comparative analysis of predictive models ................................................... 8 3. Methodology .............................................................................................................. 11 3.1. Dataset Description and modifications ............................................................... 11 3.2. Model Evaluation Metrics ................................................................................... 14 3.2.1. Data Imputation of the missing values ........................................................ 16 4. Results and discussion ................................................................................................ 19 4.1. Exploratory analysis ............................................................................................. 19 4.1.1. Exploring relationships among key variables ............................................... 19 4.1.2. Exploring price trends in geographic context .............................................. 25 4.2. Models composition ............................................................................................ 30 4.3. Model results ....................................................................................................... 31 4.3.1. Error analysis of machine learning models .................................................. 34 5. Conclusions and future works .................................................................................... 42 Bibliographical References .............................................................................................. 44 vi LIST OF FIGURES Figure 1 - Diagram that illustrates the process that was conducted in this study .................... 2 Figure 2 - Trend of variables over the years ............................................................................ 20 Figure 3 – Presence or absence of property commodities over time ...................................... 20 Figure 4 - Percentage of properties that have the selected variable. ..................................... 21 Figure 5 – Evolution of Property Condition and Energy Efficiency Certificate over time ........ 21 Figure 6 - Number of newly constructed properties with specific characteristics .................. 22 Figure 7 - Number of newly constructed properties as apartment or houses ........................ 22 Figure 8 – Property commodities analysis by property type in Rural and Non-Rual areas ..... 23 Figure 9 - Distribution of properties along the regions ........................................................... 24 Figure 10 - Relationship between GBA and Number of bedrooms ......................................... 25 Figure 11 - Evolution of real estate property prices ................................................................ 25 Figure 12 - Evolution of real estate property prices along the regions ................................... 26 Figure 13 - Average property selling prices along the regions................................................. 27 Figure 14 - Average property selling prices in the districts of Portugal ................................... 27 Figure 15 - Average property selling prices in municipality of Lisbon ..................................... 28 Figure 16 - Average property selling prices in the parish of Cascais........................................ 29 Figure 17 - Average property selling prices in the parish of Lisbon ......................................... 29 Figure 18 - Heatmap of the evolution of property selling prices in Lisbon's parishes ............. 30 Figure 19 - Scatter plot and Histogram of residuals for predicting real estate prices using Random Forest ................................................................................................................. 35 Figure 20 - Scatter plot and Histogram of residuals for predicting real estate prices using Decision Tree .................................................................................................................... 36 Figure 21 - Scatter plot and Histogram of residuals for predicting real estate prices using KNN .......................................................................................................................................... 36 Figure 22 - Scatter plot and Histogram of residuals for predicting real estate prices in Lisbon using Random Forest ........................................................................................................ 37 Figure 23 - Scatter plot and Histogram of residuals for predicting real estate prices in Lisbon using Decision Tree .......................................................................................................... 37 Figure 24 - Scatter plot and Histogram of residuals for predicting real estate prices in North using Random Forest ........................................................................................................ 38 Figure 25 - Scatter plot and Histogram of residuals for predicting real estate prices in Center using Random Forest ........................................................................................................ 38 Figure 26 - Scatter plot and Histogram of residuals for predicting real estate prices in Alentejo using Random Forest ........................................................................................................ 39 vii Figure 27 - Scatter plot and Histogram of residuals for predicting real estate prices in Algarve using Random Forest ........................................................................................................ 39 Figure 28 - Scatter plot and Histogram of residuals for predicting real estate prices in Lisbon Apartments using Random Forest.................................................................................... 40 Figure 29 - Scatter plot and Histogram of residuals for predicting real estate prices in Lisbon Houses using Random Forest ........................................................................................... 40 viii LIST OF TABLES Table 1 - Comparative analysis of predictive models .............................................................. 10 Table 2 - Variables Description ................................................................................................. 14 Table 3 - Explanation of the metrics to fulfill missing values ................................................... 15 Table 4 - Explanation of the metrics selected for evaluation of each of the models .............. 16 Table 5 - Explanation of the rules applied................................................................................ 17 Table 6 - Results of the best method to handle the missing values ........................................ 18 Table 7 - Best hyperparameters for the models ...................................................................... 31 Table 8 - Machine Learning Experimentation for Property Price Prediction ........................... 34 6 whether there is a relationship between crime rates and real estate prices in Poland. The study led them to conclude that geographic areas with lower values appeared in areas with higher crime rates. They also examine the effects of gentrification, a process that attracts high-income households and businesses, resulting in higher incomes and education levels and lower crime rates among this population. Thus, an increase in housing prices is associated with a decrease in crime. “The decline in safety coincides with the deterioration of the living conditions of the population but also reduces trust in the police and judicial system” (Foryś & Putek-Szeląg, 2017, p. 52). Crime reduces the demand for real estate in that geographic area, which reduces the area's popularity and prices. Buyers are willing to pay more to live in areas with lower crime rates so they can enjoy greater safety and a better quality of life (Buonanno et al., 2013). 2.2. PRICE FORECAST There are many studies that use different forecasting methods. We will analyze some of them and their results to determine the best method. Some studies are done using micro variables, as in our case. Variables such as number of bedrooms, number of bathrooms, size of the house, whether it has a garage, a balcony, or even a swimming pool are included in this analysis. Furthermore, real estate property prices are affected by many characteristics, some of which are related to the characteristics of a specific home. The most common variables for the model studied by (Wing & Chin, 2003) include attributes such as type, age of the building, number of bedrooms and bathrooms, facilities (e.g. swimming pool), garage, patio, gross area, and building services (e.g., air conditional, lift, etc). The application of hedonic price to real estate markets identifies a set of key variables to be included in the model, showing that the effects of one or more real estate attributes on real estate prices can be observed, while other factors being constant. (Fletcher et al., 2000) conducted a study with the aim of determining the list of variables to be included in a hedonic pricing model and found that, the number of bedrooms, bathrooms and gross area can be positively related to its price. In the research of (My-Linh, 2020) revealed that the age of the building can impact property real estate prices negatively. To estimate property prices (Pai & Wang, 2020) also included variables such as distance to the city center and proximity to the subway in his predictions, and used many methods (Decision Tree, Back Propagation Neural Networks, General Regression Neural Networks and Least Squares Vector Regression) for predict property prices. They conclude that it is possible to predict the prices using these methods and that the method that most accurately reflects real estate property prices is least squares vector regression. (Liu, 2022) research analyses the real estate market applying Multiple Linear Regression Model, the study shows a strong correlation between the income levels with real estate prices versus, the models demonstrate a high accuracy with lower prediction error, indicating its practicality in forecasting real estate market trends. Random Forest is a decision tree-based ensemble model that uses a technique called bootstrap aggregation (or bagging) to create multiple independent regression models from random samples of the training data set. It is a versatile method that can handle both regression and classification tasks. The main process involves building various decision trees by randomly selecting data points and 7 features during training, which ultimately helps improve model accuracy (Ja’afar et al., 2021). In a comparative study by (Čeh et al., 2018), the Random Forest model was compared with Linear Regression to predict real estate prices. The results show that Random Forest consistently performed better than Linear Regression model on a variety of performance metrics. Furthermore, Random Forest have lower error rates in predicting real estate prices compared to other algorithms (Shinde & Gawande, 2018). In a study conducted by (del Cacho, 2010), various models such as Naïve Neighbors, Linear Regression, Decision Trees, K-Nearest Neighbors (KNN) and Neural Networks were used to predict real estate prices. A point to highlight related to this study is the fact that Naïve Neighbors is a classifier that assumes that all variables are independent of each other. The results were evaluated based on various indicators and it was found that the Decision Tree model provided the best indicator performance in terms of real estate prices. Artificial Neural Network (ANN) have a wide range of uses, forecasting is one of the purposes so many researchers decided to apply this technique. It is able to address problems related to nonlinearity and multicollinearity. One of the advantages of this model is its versatility, it has the ability to model relationships between dependent and independent variables. (Ghodsi et al., 2010) in their research of estimation of Iranian house prices, in order to form an Artificial Neural Networking, considered economic variables including, the housing price index, GDP, and cost of construction materials, the result was a successful estimation of the prices of the variables. (Tabales et al., 2013) did forecasting for the real estate market and show that ANN has better prevision results than econometric models. The study conducted by (Rahman et al., 2019) also using ANN to forecast housing prices, concluded that ANN has the potential to forecast house prices with high performance and also confirmed the findings made by (Tabales et al., 2013), the ANN model achieved better results when tested in a large dataset. (Bahia, 2013) used two types of ANN: Feed Forward Back Propagation Neural Network (FFBP) and Cascade Forward Back Propagation Neural Network (CFBP) to predict real estate prices. The difference between these two types is that the second method, CFBP, includes a weighted connection from the input to each layer and successive layers. The conclusion of this research is that the CFBP method shows results that are closest to real prices since it is possible to adjust the weights, the results were more accurate, this study achieved more than 96% accuracy in predicting real estate prices. Other methods are also used by more researchers, such as Multiple Linear Regression, which we have previously validated (Grum & Govekar, 2016) to see the relationship between house prices and macroeconomic variables in different regions and cultures (Greece, Poland, etc.), and it turns out that there is a strong relationship between the variables studied, namely the unemployment rate and house prices, which accurately illustrates the macroeconomic impact on this market. Using macroeconomic variables, GDP, house price index, consumer index, (Li & Chu, 2017) and with the forecasting methods Back Propagation and ANN, it is concluded that these variables are not strong enough to predict house prices. Based on the final price of several houses over 4 years, (Singh et al., 2020) used three different methods: Random Forest, Gradient Boosting and Linear Regression, in order to predict house prices, the conclusion is that all forecasting models were able to predict prices but the model with higher forecasting accuracy was the Gradient Boosting. One problem that most of the previous studies have is the fact that they don’t take into account the economic situation over time, so, their studies need to be updated frequently otherwise they became 8 outdated. (Yasnitsky et al., 2021) saw this as an opportunity and developed a mass valuation for real estate in Russia based on fixed factors, location, and variable factors, economic parameters. The result of the model elaborated was that houses in different geographical locations react differently to the economic changes where they are inserted, the volume of loans, and the GDP of the country. This model is very different in that it can easily adapt to the economy and the constant changes that exist. (Hishamuddin et al., 2020) saw that not many studies combine microeconomic and macroeconomic variables, so they decided to consider both in their paper to have a vision in a short and long term for property prices, the method chosen was ANN. Using R² in error measurement as a basis, they conclude that the percentage of error is less when R² has a high value when only macroeconomic variables were considered. When only microeconomic variables were used alone the results were really weak, and when both variables were combined, the results were better than using microeconomic variables alone but worse than using macroeconomics variables alone. Therefore, it is necessary to study this combination of variables in more detail to avoid value discrepancies and to obtain a more reliable price prediction. With this study, it is possible to see that there is a gap in research and an opportunity to explore the combination of these two macro variables. We need to consider both the micro variables described above and the macroeconomic variables such as inflation, unemployment rate, interest rate, etc. 2.2.1. Comparative analysis of predictive models The real estate market is influenced by several quantitative and qualitative variables, making price forecasting a complex task. To address this challenge, various predictive models have been used to fill in the null values that we have in the data and to estimate real estate prices. This research aims to examine and compare several predictive models, including Artificial Neural Network (ANN), Linear Regression, Decision Trees, K-Nearest Neighbor Imputation (KNN), Random Forest, and Gradient Boosting. Each of these models has unique strengths and limitations that make it suitable for different scenarios. By evaluating and comparing these models against each other, we aim to provide valuable insights into their performance and effectiveness. Table 1 lists various forecasting models, each with a brief description, strengths, and limitations. Among the authors who studied predictive models, those who are mentioned are part of the research carried out that gave rise to the table. Predictive Model Description and Definition Strengths Limitations ANN (Hush & Horne, 1993) It's a type of Neural Network algorithm that consists of interconnected nodes or neurons organized into layers, usually including input, hidden, and output layers. These networks take input data and predict an output based on it. During training, neural networks adjust the connections' weights to learn • Capable of handling nonlinear and complex data. • Suitable for big data applications due to their ability to model intricate relationships. • Requires a large training dataset for optimal performance. • Prone to overfitting if not carefully regularized. 9 complex patterns and make predictions. Linear Regression (Montgomery et al., 2021) Is a statistical model that establishes a linear relationship between predictor variables and the target variable. It assumes a linear combination of features and finds coefficients that minimize the error between predicted and actual values. • Simple and easy to interpret, making it a good choice for initial insights. • Wide applicability to a extend of problems. • Method limited to linear relationships between variables, which may not capture complex patterns. • Sensitive to outliers and multicollinearity. Decision Trees (de Ville, 2013) Are constructed by algorithms that explore different ways of splitting the data into distinct segments. They make decisions based on feature splits, creating a tree where each node represents a decision. The tree is split based on the feature that provides the best information gain. • Easily interpretable models, as they mimic human decision-making processes. • Can handle both numerical and categorical data. • Tendency to overfit with deep trees, which requires pruning or ensemble methods. • Sensitive to small variations in the training data. KNN (Weinberger & Saul, 2009) KNN is a non-parametric algorithm that predicts a target variable based on the majority class of its k-nearest neighbors in a feature space. It determines the target value by considering the labels of these neighbors. Prediction with KNN requires define the chosen variables, the distance metric to calculate the distance between observations and the number of neighbors. • Ability to adapt to complex data patterns, especially when the number of neighbors (k) is appropriately chosen. • Performs well on small datasets and with few features. • Sensitive to the choice of 'k', which can significantly affect results. • Is influenced by outliers in the data, leading to inaccurate predictions. Random Forest (Oshiro et al., 2012) Random Forest is an ensemble method that combines several Decision Trees. This model is particularly known for its ability to effectively handle a large number of features and • Reduces overfitting through ensemble averaging. - Handles missing data effectively • The relationship between the response and the independent attributes is 10 efficiently process extensive datasets. Also improves prediction accuracy and reduce overfitting by aggregating prediction from multiple decision trees. without preprocessing. complicated to understand. • Tend to have longer training times compared to other methods, so is less suitable for real-time applications or very large datasets. Gradient Boosting (Hastie et al., 2009) Is a method that sequentially constructs an ensemble of weak learners (usually decision trees) to create a strong predictive model. It builds trees sequentially, focusing on the mistakes made by previous trees. This method gained popularity due to the superior performance of Decision Trees and led to the development of algorithms such as XGBoost and LightGBM. • High accuracy and effectiveness across many scenarios. • Handles missing data effectively. • Can be sensitive to outliers in the training data. • Prone to overfitting, especially when the algorithm is allowed to create complex models. Table 1 - Comparative analysis of predictive models 11 3. METHODOLOGY The objective of this study is to build a property price forecasting model using predictive models. Property price forecasts are designed to help homebuyers understand future price ranges and plan their finances in advance. In addition, property price forecasts are also beneficial for real estate investors to understand the trend of property prices in a particular region. This study refers to Portugal Continental and was a focus on Lisbon since Lisbon is the capital of Portugal. Lisbon is where there are more data and exist a large difference in price variation and where the differences between cultures, trends and lifestyles are most pronounced, where is a lot of business activity and tourism, therefore this allows for a comprehensive analysis with abundant data. To make accurate forecasts, we need suitable mathematical models to estimate how time series data generate house prices. In this context, CRISP-DM method was adapted to this situation, as discussed by (Shearer, 2020). Analyzing current trends and predicting future trends is becoming increasingly important today. Predictive models are gaining increasing value in organizations that face the challenge of choosing the right technology for the business and understanding how to use existing data (Nwagwu et al., 2021). The real estate market is known for its volatility, characterized by fluctuations over time and continually changing trends. Given the complexity of the real estate market, which often exhibits nonlinear relationships, it becomes necessary to leverage historical data and employ machine learning methods for analysis (Han, 2018). Machine learning offers the advantage of automatically learning patterns and insights from historical data, making it well suited for handling the difficulties of the real estate market. For the construction of the prediction model, the programming language selected was Python. It is the most used language worldwide occupying the first place in October 2023 1 , and is a user-friendly interface as it is easy to understand and has a wide variety of libraries available, which helps to increase of those uses this language saving programming time that would be manual. In line to ensure that the information is accurate in this context, the data were subject to treatment and rules were defined. Before starting to develop the model, it is necessary to process data that involves importing files in CSV format, Exploration and Data Understanding, Data Pre-processing, Feature Selection, Modelling and Performance Assessment. 3.1. DATASET DESCRIPTION AND MODIFICATIONS The study began by importing data from two Excel files into Jupyter. One of these files contained the year of construction of the properties, while the other file held a wide range of variables that constitute the dataset, such as the type of property (house or apartment), number of bedrooms, energy efficiency certificate, gross building area, property’s condition, the presence of garage, swimming pool, terrace and patio, contained as well variables geographic related, such as parish number, postal code, latitude and longitude, and lastly information linked to real estate market prices, the last market appearance date and the selling price observed. To verify if a property had multiple values in the construction year variable, inconsistencies were checked, and each property ID was assigned a unique construction year. 1 TIOBE Index - TIOBE 12 A merge operation was conducted between two Excel files to create a unified dataset. The data for this study consisted of properties up to the construction year of 2024 and there are historical price sales between 2017 and 2022. Geographical information, such as parish number and postal code, allowed for the augmentation of the dataset with additional information. This data was derived from two external files 2 . The following columns were added: district, zone, municipality, and parish name, along with the rural/non-rural designation. Various transformations were applied to these new variables to make them usable. The properties have been classified into zones and rural and non-rural according to the municipalities, there are five zones covering the dataset and Portugal, the division is done according to the characteristics of the zones and municipalities, so we will have properties in the same zone more similar to each other2. Two specific variables that had no significant value to the dataset and only added complexity were removed, such as latitude and longitude, as their information was found to be redundant since they provided information that could be derived from the postal code variable. Latitude and longitude represent geographic coordinates and are useful when working with map or geocoding services. However, in this case, the latitude and longitude do not change for the same postal code, which is actually incorrect, so we consider removing these two variables and keeping the dataset concise. Regarding the year of construction, the dataset compilation revealed several inconsistencies and nonsensical years, including the year 1050. As a corrective approach, all properties with a construction year prior to 1755 were removed from the dataset. This decision was influenced by historical events, notably the devastating earthquake that struck Lisbon in 1755, leading to widespread destruction by tsunami and fire. Given the severity of the damage, it was assumed that none of the houses constructed before that year remained habitable. Consequently, these properties were excluded from the analysis. The removal of houses constructed before 1755 and the handling of inconsistencies, such as the year 1050, ensured data quality and reliability in the subsequent analysis. Several transformations and modifications were made to simply the data. Start by transforming the property ID variable into numerical format to facilitate further transformations. The property condition variable was transformed into numerical values ranging from 1 to 4. The rural variable was converted into a binary format, with 0 indicating a rural location and 1 representing a non-rural location. Further analysis revealed that the EEC (Energy Efficiency Certificate) variable could take on nine distinct letters that significantly different EEC levels. To simplify this variable, it was grouped into four distinct classes: Class 1 includes certificates A and A+, Class 2 encompasses certificates B and B-, Class 3 consists of certificates C and D, and Class 4 comprises the remaining certificates E, F, and G. The modified dataset consists of 326537 rows representing the number of properties and includes 26 variables that will facilitate house price prediction modeling. Below, in table 2, is presented all the 26 variables selected variables from the modified dataset, which will enable us to build the most accurate predictive model. Is also present the two extra variables during the forecast. 2 https://www.gpp.pt/images/Estatisticas_e_analises/Estatisticas/associadasmedidasapoio/Territorios_Rurais.pdf http://www.proder.pt/ResourcesUser/Documentos_Diversos/33/PDRc_Freg_ZRurais_NUTIIs_rev2_corrigido.pdf 13 Variable Description Data Type Property ID The unique identifier of the properties Object Property Type Property type. 1 if is an apartment and 2 for a house Integer Nº Bedrooms Number of bedrooms Integer EEC Energy Efficiency Certificate: Number 1 includes certificates A and A+, Number 2 certificates B and B-, Number 3 consists of certificates C and D, and Number 4 comprises the remaining certificates E, F, and G. Integer GBA Gross Building Area Integer Parish Parish Object Postal Code Postal Code Object Garage Indicates whether the property has a garage or not Bool Terrace Indicates whether the property has a terrace or not Bool Pool Indicates whether the property has a swimming pool or not Bool Patio Indicates whether the property has a patio or not Bool Property Condition The state of conservation of the house. It can be classified as good, bad, new, or used. For each state was assigned a number Integer Conservation State Verified Indicates if the conservation state was provided by clients or verified with photos Bool Last Day in Market Date of the last market update Datetime Initial Offer Date Date of the initial offer Datetime Observed Selling Price The selling prices that were observed by the company Integer Construction Year Year of construction Integer 14 District District Object Region Indicates one of the five regions into which Portugal was divided (North, Center, Lisbon, Alentejo and Algarve) Object Municipality Municipality Object Parish Name Name of the parish Object Last Market Update Year Year of the last market update Integer Initial Offer Year Year of the initial offer Integer Rural Indicates whether the property is located in a rural area or not Bool Decade Decade of construction (e.g., 50’s) Object Century Century of construction (e.g., 20) Integer Predicted Selling Price The selling prices that were predicted by the different models Float Square meter Price Difference Price per square meter. Difference between observed and predicted prices Float Table 2 - Variables Description Since this dataset contains six variables with a lot of missing values, further transformations were performed to impute the data, considering the correlation between the variables. Based on literature review, the following models were selected: Decision Tree Imputation, Random Forest Imputation, K- Nearest Neighbor Imputation (KNN), Artificial Neural Network Imputation (ANN), and Linear Regression Imputation. The model chosen for each variable was the one that gave the best results compared to all the models studied, in terms of performance metrics (further explained in the next section 3.2). 3.2. MODEL EVALUATION METRICS In this project, a variety of evaluation metrics have been employed to assess the performance of different models, both in filling missing values and predicting property prices. These metrics serve as essential tools to gauge the effectiveness of the models. To evaluate the performance of data imputation models, we focus on the metrics presented in table 3, based on the classification results. 15 Metric Definition Interpretation of the result Precision Measures the proportion of correctly imputed values (true positives) out of the total imputed values. A high precision score indicates that the method is adept at accurately filling in missing data. Recall Quantifies the ratio of correctly imputed values (true positives) to the total actual missing values. A higher recall score implies that the method effectively captures missing data. F1-Score The F1-score strikes a balance between precision and recall, offering a single metric to assess overall performance. It combines both precision and recall into a unified score, making it valuable for assessing the overall quality of data imputation. A higher F1-Score indicates a better balance between precision and recall, meaning a better performance predicting missing values. Support Represents the number of instances for each class, reflecting the distribution of missing data points across different categories. A higher support indicates that the model’s predictions are more reliable and trustworthy in impute missing values. Table 3 - Explanation of the metrics to fulfill missing values These metrics are fundamental for evaluating the performance of data imputation models in accurately filling missing values. Additionally, they guide us in choosing the most effective approach to ensure the reliability and completeness of our dataset, which, in turn, contributes to more accurate predictions of house prices. For the prediction of property prices, it is important to evaluate the performance of each model developed using different methods. The emphasis lies on six metrics: Accuracy, Mean Absolute Error (MAE), Mean Square Error (MSE), Root Mean Square Error (RMSE), Mean Absolute Percentage Error (MAPE) and R² Score. Before using these five evaluation indicators, it is necessary to understand their meanings and consider their interpretation within the specific context of this project. In table 4 is represented an explanation of the metrics to evaluate each of the models. Metric Definition Interpretation of the result Accuracy Measures the proportion of correctly classified observations relative to the total. The higher the percentage, the better the performance of the model. MAE Measures the difference between two continuous variables, translated into the average of the errors of a set of forecasts. A lower value indicates that the models is capable to predict with accuracy the values. 22 As we observe an increase in the number of newly constructed properties, it is important to analyze the significance of property commodities in these new houses. From Figure 6, we can conclude that new properties tend to exhibit these characteristics more notably. Garage variable appear in more than half of new constructions, providing information about which builders and buyers are increasingly valuing. In the Figure 7, we can also see the difference between the number of properties being built as apartments versus the number of homes, with more apartments being constructed. Figure 6 - Number of newly constructed properties with specific characteristics Figure 7 - Number of newly constructed properties as apartment or houses 23 To examine the geographic relationship between properties in rural or non-rural areas, analyzes were conducted to assess the behavior of property commodities in relation to the property types. In Figure 8, the difference between the percentage of the number of properties with and without these of property commodities are not substantial. The most notable difference can be observed in the property type, apartment, or a house. There are more apartments in non-rural areas compared to rural areas, whereas in rural areas, there is a higher prevalence of houses. The reason for this distinction can be attributed to urbanization trends, where non-rural areas often witness higher population densities, leading to a greater demand for apartments. Conversely, rural areas tend to have more space available, which encourages home construction. Figure 8 – Property commodities analysis by property type in Rural and Non-Rual areas Following the geographical analysis of property characteristics, a thorough study of property commodities and property types was carried out to understand their distribution across the five zones in Portugal, as shown in Figure 9. The garage variable displayed a consistent percentage throughout the country, with the absence of garages being more common. 24 Remarkably, the swimming pool variable stood out in the Algarve region, where approximately 10.73% of properties featured this variable. In the southernmost regions of country, such as Alentejo and Algarve, the presence of terrace and patio was significantly more common. The Lisbon region has a lower proportion of properties classified as Houses, while the zones Center and Alentejo have a more balanced ratio between apartments and houses. It is notable that the majority of properties in the Alentejo are considered Rural, making it the predominantly rural area in the country. Figure 9 - Distribution of properties along the regions 25 Figure 10 illustrates the existence of a moderately strong positive relationship between the variables Groos Building Area and the number of bedrooms. The correlation coefficient is 0.68, which is a relatively high relationship, indicating a clear trend where an increase in the gross private area of properties corresponds to an increase in the number of rooms. Figure 10 - Relationship between GBA and Number of bedrooms 4.1.2. Exploring price trends in geographic context Continuing the analysis of real estate property prices and examine their development in different contexts. Figure 11 provides an insight into the average development of property prices in the years considered. It is evident that the prices in 2018, there was a significantly increase compared with the previous year. Throughout the years 2018 to 2020, there were no substantial fluctuations, and from the year 2020 onwards, prices have consistently been on the rise. Figure 11 - Evolution of real estate property prices 26 In Figure 12, the progression of property prices across the five regions and the study years is represented. The North region exhibits a gradual and less pronounced growth, while the Algarve region experiences slight price fluctuations. The Center and Alentejo zones have maintained their values. In contrast, the Lisbon region boasts the highest real estate prices prices and displays a more significant price variation, particularly marked by price increases. Figure 12 - Evolution of real estate property prices along the regions 27 In order to organize the zones from the highest average selling prices to the lowest, the Figure 13 is presented. It is evident that Lisbon region has the highest real estate prices, closely followed by the Algarve region. The Center region is characterized by more affordable property prices. Figure 13 - Average property selling prices along the regions It is important to have a sense of the price disparities among the districts of Portugal. Confirming the previous information, Figure 14, illustrates that the Lisbon district has the highest average property prices, closely followed by the Faro district. In contrast, the Guarda district emerges as the most budget-friendly option. Remarkably, the average housing price in Lisbon is over three times higher than that in Guarda. In terms of pricing within this market, Lisbon is 37% more expensive than the second most populous district in the country, which is Porto. Figure 14 - Average property selling prices in the districts of Portugal 28 Given that Lisbon is the district with the highest real estate property prices, it becomes important to narrow down the geographical analysis. Consequently, the Lisbon municipality was examined, and Figure 15 appears. Among the municipalities within the district, Cascais stands out with the highest average housing prices, closely followed by the Lisbon municipality, with little difference between the two values. In contrast, Azambuja, a municipality in the Lisbon district, has the lowest average housing prices, with a value that is over three times cheaper compared to Cascais. Figure 15 - Average property selling prices in municipality of Lisbon Since Cascais and Lisbon were the municipalities with the highest real estate selling prices, Figures 16 and 17 represent the prices within the respective parishes. In Cascais, the difference between the parish with the highest and the lowest prices is approximately the double. In Lisbon, the differences are even greater, with prices varying by almost four times from the parish with the highest average prices to the one with the lowest. 29 Figure 16 - Average property selling prices in the parish of Cascais Figure 17 - Average property selling prices in the parish of Lisbon 30 As we can see, real estate property prices in Lisbon are higher and the differences between parishes are very noticeable. To better understand how prices develop in this parish, the as shown in Figure 18 were created. It is possible to examine the price evolution and maximum price spikes in each parish of Lisbon. In the year 2017, properties with the highest prices were located in the Santa Maria Maior and Santo António parishes. In 2018, the Avenidas Novas parish experienced a significant price increase, becoming the parish with the highest real estate property prices. In 2019, the Parque das Nações parish doubled in value compared to 2017, now ranking among the parishes with the highest housing prices, consistently increasing in price over the years. By 2022, we can conclude that the top five parishes with the highest property prices, in descending order, are Avenidas Novas, Parque das Nações, Santo António, Belém, and Campolide. The parishes with lower prices that have remained comparatively more affordable include Ajuda, Santa Clara, Beato, Penha da França, and Marvila. Figure 18 - Heatmap of the evolution of property selling prices in Lisbon's parishes 4.2. MODELS COMPOSITION The final dataset represents a culmination of the best models previously tested to fulfill missing values. With these refined variables now integrated, the dataset stands prepared for the accurate prediction of property prices. Next, we perform a rigorous comparison of models to discern their effectiveness in the real estate context. Through systematic evaluation and careful analysis based on the previously mentioned metrics, we aim to identify the model that performs best for the real estate price forecasting task and the existing differences when analyzed in different geographic context. 31 For all the predicting methods, the dataset was divided into two sets, the training set, and the test set. The original dataset was also split into independent and dependent variables, as this split is essential for evaluating model performance using previously unseen data. The split between training and testing dataset was explored for the different scenarios. The split used was 80% - 20%, which means 20% of the data is used for the testing dataset and the remaining 80% of the data in the training. After training, predictions were made on the test basis. These forecasts represent estimates of the dependent variable based on the independent variable. In all models, the analysis of feature importance was conducted, and these features were carefully chosen to create the forecasting inputs. The main focus is to include features that have a strong correlation with the target variable and show a significant impact on property selling price. During model testing and validation, the consequences of including or excluding certain features were evaluated. Attributes that significantly improved predictive performance of the models were incorporated into the final input. This deliberate selection ensures that the forecasts are optimized, as it focuses on the features that exert the most significant impact on the predictions, enhancing the overall accuracy and reliability of the models. To determine the performance metrics of the regression models, several metrics were evaluated. After training the model with the different forecast models, add the price prediction to the database by creating a new column "Predicted Selling Price". To optimize the performance of our machine learning models, an extensive experiment was conducted to evaluate various combinations of hyperparameters. The objective was to identify the optimal settings for each algorithm, ensuring that the models were well-tuned and highly accurate. Table 7 highlights the specific hyperparameters used in the prediction model. Machine Learning Models Best Hyperparameters Random Forest Random State: 42. N estimators: 100. Min Samples Split: 2. Min Samples Leaf: 2. Max Features: sqrt. Criterion: MSE. Bootstrap: True Decision Trees Splitter: best. Random State: 42. Min Samples Split: 5. Min Samples Leaf: 2. Max Features: sqrt. Criterion: MSE KNN Weights: uniform. N neighbors: 5. Metric: minkowski. Leaf size: 16. Algorithm: kd_tree Table 7 - Best hyperparameters for the models 4.3. MODEL RESULTS Predicted real estate prices start with all properties in the dataset and use three different forecast models: Random Forest, Decision Tree and KNN. The results are shown in Table 8. Random Forest model achieved the highest R² score, 82,34% which indicates that approximately 82% of housing prices can be explained by the correlated variables. By comparing the price between “Observed Selling Price” and the model predicted price, and evaluating this price comparison using the MAE metric, it is found that the MAE between the estimated price and the predicted price is 21.969€. 38 Figure 24 - Scatter plot and Histogram of residuals for predicting real estate prices in North using Random Forest Figure 25 - Scatter plot and Histogram of residuals for predicting real estate prices in Center using Random Forest 39 Figure 26 - Scatter plot and Histogram of residuals for predicting real estate prices in Alentejo using Random Forest Figure 27 - Scatter plot and Histogram of residuals for predicting real estate prices in Algarve using Random Forest The scatter plot in Figures 22 to 27 demonstrates uniformity along the regions, exhibiting similar patterns for each region, with the Algarve region displaying a higher dispersion of points, particularly those deviating from the diagonal line. Histograms in Figures 22 to 27, for different regions illustrate varying distributions. The Alentejo region presents higher density with multiple columns concentrated near zero, whereas the other regions predominantly exhibit a primary column near zero, complemented by smaller bars around this central point. These observations suggest that the model potentially showcases higher accuracy and consistency in predicting property prices within the Alentejo region compared to other regions. 40 4.3.1.3. Model performance overview in the property types Figure 28 - Scatter plot and Histogram of residuals for predicting real estate prices in Lisbon Apartments using Random Forest Figure 29 - Scatter plot and Histogram of residuals for predicting real estate prices in Lisbon Houses using Random Forest From the scatter plot in Figures 28 and 29 of apartments and houses, it is apparent that both exhibit similar characteristics with a concentration of points around zero and an alignment along the diagonal line. The histogram in Figures 28 and 29 for apartments reveals two significantly tall columns concentrated around zero. On the other hand, in the case of houses, a prominent column centered at zero is followed by smaller columns in the vicinity of zero. This implies that predictions for apartments and houses are mostly close to the actual values, showcasing higher accuracy in predictions for both property types. The more prominent columns around zero signify a higher frequency of predictions closer to the actual prices, demonstrating more consistent performance in predicting property prices, in both models, with a significantly lower error. 41 This study shows that among the three real estate property price prediction models analyzed (Random Forest, Decision Tree and KNN), the Random Forest model becomes the first choice for real estate price prediction. The results of the scatter plot and histogram analysis show that the prediction performance for the two property types, apartments, and houses, is consistent, with deviations close to zero. Alignment along the diagonal shows that the predicted and actual values of the two models are in good agreement. These graphical observations are consistent with the statistical results presented in table 8, where the Random Forest model has the lowest error margin, followed by the Decision Tree model, while the KNN model has relatively high prediction errors. Correlating these graphical observations with the statistical metrics presented earlier, in table 8, it is clear that Random Forest models consistently outperform Decision Tree and KNN models. The points around the zero point in the scatterplot and the higher columns in the histogram are significantly concentrated, especially in the case of Random Forest, confirming the high prediction accuracy. This is consistent with the results of the performance table and supports the conclusion that the Random Forest model has a lower error rate compared to other models, making it the most reliable model for predicting property real estate prices. 42 5. CONCLUSIONS AND FUTURE WORKS The purpose of this study was to predict real estate property prices and gain a deeper understanding of the Portuguese property market. To achieve this goal, a thorough investigation was conducted into the most appropriate methods to handling the data at hand, considering the nature and historical context of the data. The literature review plays a crucial role in selecting the different methods that best suit the research objectives. Data preprocessing includes data cleaning, exploratory data analysis, and examination of trends and correlations over time. This allowed us to calculate property prices across Portugal and analyze differences between regions, highlighting the impact of different variables and geographical features on price disparities. The results obtained from the predictive models demonstrated the effectiveness of the chosen approach. These models show extremely high accuracy, with few, relatively minor errors, which may have limited impact within the context of the real estate market. This main advantage of this study is the ability to predict future developments and provide customers with valuable insights to make informed decisions. This outcome is consistent with the main objectives of the project. Despite its important findings, this work has certain limitations that must be acknowledged. Some have to do with the dataset itself. In particular, the lack of certain characteristics, such as the number of bathrooms, the presence of an elevator or the floors of the property, creates challenges in determining the price of a property. Due to the omission of these variables and the lack of clear correlations in the data set, these features were not added. Furthermore, the dataset contains a large number of missing values, making data imputation a complex and less reliable process. While potentially valuable, excluding latitude and longitude data can provide precise geographic coordinates that allow you to determine the exact location of a property. In many cases, this information can be derived from postal codes already included in the data set. However, it is important to note that postal codes cover larger areas and different properties within the same postal code may have different coordinates. For example, two houses with the same zip code but located on opposite sides of a street or in different buildings will have different latitude and longitude coordinates. Therefore, the accuracy of latitude and longitude in this dataset is inconsistent. Future work should focus on using coordinates to improve accuracy. Economic, political, and social factors also have a significant impact on the real estate market over time. Models based on historical data may not accurately predict such changes. Furthermore, the skewed price distribution of the dataset affects forecast accuracy, especially in extreme cases. This study marks an important step in fully understanding the Portuguese dynamic real estate market. By using the power of predictive models and geospatial data, is possible to provide valuable insights to customers and stakeholders to shape a more well-known real estate market. In view of these limitations, it is important to realize that this study represents a snapshot of the dynamic real estate market and provides the foundation for future work and improvement. 43 Realizing this work brings it closer to the ultimate goal: to help individuals, companies and investors make data-oriented decisions in dynamic and changing real estate landscape. I hope this research can support and encourage further research in this field. 44 BIBLIOGRAPHICAL REFERENCES Agnello, L., & Schuknecht, L. (2011). Booms and busts in housing markets: Determinants and implications. Ahmad, N., Menegaki, A. N., & Al-Muharrami, S. (2020). Systematic Literature Review of Tourism Growth Nexus: An Overview of the Literature and a Content Analysis of 100 Most Influential Papers. Journal of Economic Surveys, 34(5), 1068–1110. https://doi.org/10.1111/joes.12386 Ahn, J. J., Byun, H. W., Oh, K. J., & Kim, T. Y. (2012). Using ridge regression with genetic algorithm to enhance real estate appraisal forecasting. Expert Systems with Applications, 39(9), 8369–8379. https://doi.org/10.1016/j.eswa.2012.01.183 Akinsomi, O. K., Mkhabela, N., & Taderera, M. (2018). The role of macro-economic indicators in explaining direct commercial real estate returns: Evidence from South Africa. Journal of Property Research, 35, 1 to 28. https://doi.org/10.1080/09599916.2017.1402071 Alhowaish, A. K. (2016). Is Tourism Development a Sustainable Economic Growth Strategy in the Long Run? Evidence from GCC Countries. Sustainability, 8(7), Article 7. https://doi.org/10.3390/su8070605 Alkali, M., Sipan, I., & Razali, M. (2018). An Overview of Macro-Economic Determinants of Real Estate Price in Nigeria. International Journal of Engineering and Technology(UAE), 7, 484–488. https://doi.org/10.14419/ijet.v7i3.30.18416 Badarinza, C., & Ramadorai, T. (2018). Home away from home? Foreign demand and London house prices. Journal of Financial Economics, 130(3), 532–555. https://doi.org/10.1016/j.jfineco.2018.07.010 Baffoe-Bonnie, J. (1998). The Dynamic Impact of Macroeconomic Aggregates on Housing Prices and Stock of Houses: A National and Regional Analysis. The Journal of Real 45 Estate Finance and Economics, 17(2), 179–197. https://doi.org/10.1023/A:1007753421236 Bahia, I. S. H. (2013). A Data Mining Model by Using ANN for Predicting Real Estate Market: Comparative Study. International Journal of Intelligence Science, 3(4), Article 4. https://doi.org/10.4236/ijis.2013.34017 Barron, K., Kung, E., & Proserpio, D. (2021). The Effect of Home-Sharing on House Prices and Rents: Evidence from Airbnb. Marketing Science, 40(1), 23–47. https://doi.org/10.1287/mksc.2020.1227 Biagi, B., Brandano, M. G., & Lambiri, D. (2015). Does Tourism Affect House Prices? Evidence from Italy. Growth and Change, 46(3), 501–528. https://doi.org/10.1111/grow.12094 Brzezicka, J. (2020). Towards a Typology of Housing Price Bubbles: A Literature Review. Housing, Theory and Society, 38, 1–23. https://doi.org/10.1080/14036096.2020.1758204 Buonanno, P., Montolio, D., & Raya-Vílchez, J. M. (2013). Housing prices and crime perception. Empirical Economics, 45(1), 305–321. https://doi.org/10.1007/s00181-012- 0624-y Čeh, M., Kilibarda, M., Lisec, A., & Bajat, B. (2018). Estimating the Performance of Random Forest versus Multiple Regression for Predicting Prices of the Apartments. ISPRS International Journal of Geo-Information, 7(5), Article 5. https://doi.org/10.3390/ijgi7050168 Cellmer, R., & Trojanek, R. (2020). Towards Increasing Residential Market Transparency: Mapping Local Housing Prices and Dynamics. ISPRS International Journal of Geo- Information, 9(1), Article 1. https://doi.org/10.3390/ijgi9010002 46 Cheng, I.-H., & Xiong, W. (2014). Financialization of Commodity Markets. Annual Review of Financial Economics, 6(1), 419–441. https://doi.org/10.1146/annurev-financial- 110613-034432 Cocola-Gant, A., & Gago, A. (2021). Airbnb, buy-to-let investment and tourism-driven displacement: A case study in Lisbon. Environment and Planning A: Economy and Space, 53(7), 1671–1688. https://doi.org/10.1177/0308518X19869012 Crowe, C., Dell’Ariccia, G., Igan, D., & Rabanal. (2012). Policies for Macrofinancial Stability: Managing Real Estate Booms and Busts. Cunha, A. M., & Lobão, J. (2021). The effects of tourism on housing prices: Applying a difference-in-differences methodology to the Portuguese market. International Journal of Housing Markets and Analysis, 15(4), 762–779. https://doi.org/10.1108/IJHMA-04- 2021-0047 de Ville, B. (2013). Decision trees: Decision trees. Wiley Interdisciplinary Reviews: Computational Statistics, 5(6), 448–455. https://doi.org/10.1002/wics.1278 Dehesh, A., & Pugh, C. (2000). Property Cycles in a Global Economy. Urban Studies, 37(13), 2581–2602. https://doi.org/10.1080/00420980020080701 del Cacho, C. (2010, December 11). A comparison of data mining methods for mass real estate appraisal [MPRA Paper]. https://mpra.ub.uni-muenchen.de/27378/ Fama, E. F. (1991). Efficient Capital Markets: II. The Journal of Finance, 46(5), 1575–1617. https://doi.org/10.1111/j.1540-6261.1991.tb04636.x Fletcher, M., Gallimore, P., & Mangan, J. (2000). Heteroscedasticity in hedonic house price models. Journal of Property Research, 17(2), 93–108. https://doi.org/10.1080/095999100367930 47 Foryś, I., & Putek-Szeląg, E. (2017). THE IMPACT OF CRIME ON RESIDENTIAL PROPERTY VALUE - ON THE EXAMPLE OF SZCZECIN. Real Estate Management and Valuation, 25(3), 51–61. https://doi.org/10.1515/remav-2017-0022 Ghodsi, R., Boostani, A., & Faghihi, F. (2010). Estimation of Housing Prices by Fuzzy Regression and Artificial Neural Network. 2010 Fourth Asia International Conference on Mathematical/Analytical Modelling and Computer Simulation, 81–86. https://doi.org/10.1109/AMS.2010.29 Goodhart, C., & Hofmann, B. (2008). House Prices, Money, Credit and the Macroeconomy. Grum, B., & Govekar, D. K. (2016). Influence of Macroeconomic Factors on Prices of Real Estate in Various Cultural Environments: Case of Slovenia, Greece, France, Poland and Norway. Procedia Economics and Finance, 39, 597–604. https://doi.org/10.1016/S2212-5671(16)30304-5 Han, J. H. (2018). Comparing Models for Time Series Analysis. Wharton Research Scholars. https://repository.upenn.edu/wharton_research_scholars/162 Hastie, T., Friedman, J., & Tibshirani, R. (2009). The Elements of Statistical Learning. Springer. https://doi.org/10.1007/978-0-387-21606-5 Hishamuddin, M., Ali, H., Achu, K., Binti, R., Abdul Jalil, R., Folake, A., & Yakub, A. (2020). Journal of Critical Reviews THE EFFECT OF ADOPTING MICRO AND MACROECONOMIC VARIABLES ON REAL ESTATE PRICE PREDICTION MODELS USING ANN: A SYSTEMATIC LITERATURE REVIEW. Journal of Critical Reviews, 7, 2020. https://doi.org/10.31838/jcr.07.11.88 Housing price statistics—House price index. (2023). https://ec.europa.eu/eurostat/statisticsexplained/index.php?title=Housing_price_statistics_-_house_price_index Hush, D. R., & Horne, B. G. (1993). Progress in supervised neural networks. IEEE Signal Processing Magazine, 10(1), 8–39. https://doi.org/10.1109/79.180705