## 4 Data Collection and Analysis  
Data collection was obtained using Uber's Application Programming Interface (API). It was not possible to obtain information from other ride-hailing companies operating in the city (such as Cabify), since their APIs did not provide the availability of that information. Given the lack of up-to-date official empirical data on ride-hailing demand in Spain, ride-hailing prices can serve as a good proxy for estimating the level of demand, as the supply of ride-hailing services in Spain is very steady since car licenses are limited and most of the drivers work full time [22; 27]. Using the web-scraping technique, a script was created in which the computer was taught to find the data that were deemed appropriate [28]. These tools allow for the real-time collection of requested ride information while controlling for the latitude and longitude coordinates of the chosen OD points (as was conducted by [PERSON] et al., 2021 [5], and [PERSON] et al., 2022 [19]). This study is not intended to compete with existing open tools for fare prediction (such as Uber's Fare Estimator ([[https://www.uber.com/global/en/price-estimate/](https://www.uber.com/global/en/price-estimate/)]([https://www.uber.com/global/en/price-estimate/](https://www.uber.com/global/en/price-estimate/)), accessed on 10 January 2022) and UberFareFinder ([[https://uberfarefinder.com/](https://uberfarefinder.com/)]([https://uberfarefinder.com/](https://uberfarefinder.com/)), accessed on 10 January 2022)), but rather to define a framework to identify the issues of ride-hailing fare prediction and the errors associated with it. To collect information about ride-hailing fares, 10 locations in the city of Madrid were selected as the origin and destination (OD) of the requested rides (see Figure 1). These locations were chosen to cover the city uniformly, including spots of high demand (e.g., airports, public transport stations, etc.). Ride-hailing demand is high at three special locations in the city of Madrid (i.e., Madrid-Barajas Airport, Atocha Train Station, and Chamartin Train Station). Then, using a GIS tool, another seven points were chosen to uniformly cover the city. In the end, 10 locations in the city of Madrid were defined (making up a network with 90 potential routes). Figure 1: Madrid city and selection of the ODs of the requested rides. For each ride requested through the Uber API, the following data were gathered: (i) fare; (ii) trip distance; (iii) trip duration; and (iv) trip request time (with year, month, day, and hour information). The Uber fare represents the cost of the ride as displayed by the app. The trip distance and duration indicate the distance and travel time required to travel to a specific OD. Data were collected through the Uber API and stored at 1 h intervals over 10 months (from September 2018 to June 2019), and 667,051 entries were collected. Data cleaning was required in cases where the fare, distance, and travel time variables had zero values. After the data cleaning process, the final dataset ended up containing 665,977 entries (99.84% of the original sample). Additional exogenous variables were added using feature engineering techniques (the process of extracting characteristics, properties, and attributes from raw data using domain knowledge) and queries to other information sources in addition to the variables obtained via the Uber API. Specifically, information on delay, month, and hour (time of day) was extracted. Other sources of information were consulted to obtain additional data on variables that may influence demand, such as rain precipitation, business days and holidays, peak hours, and taxi strike periods. All these new variables were incorporated into the predictive models to better explain the results. Since the Uber API's travel time is estimated based on current traffic conditions, the delay variable was calculated as the difference between the travel time of an OD pair and the shortest travel time for that OD pair.