Humans are bound to move inter-urban areas on a daily basis, and understanding human mobility is vital to explain the processes related to this human phenomenon . Human mobility is an interdisciplinary topic with inﬂuence from multiple areas of knowledge , such as geography, physics, and social sciences. Better models to describe human mobility can support urban planning activities [3, 4, 5, 6], help forecast the spread of epidemics [7, 8, 9], and prevent catastrophic events .
Throughout decades, several laws were stated to describe the mobility phenomenon, such as the laws of migration  and the law of intervening opportunities , but just recently they were revealed not to be suitable to most mobility-related scenarios . Consequently, we still lack an accurate model to understand the complexities behind this human behavior, especially with respect to the pendular movement in inter-urban areas.One of the big problems to solve in human mobility is to predict the ﬂow of people from one area to another, which consists of estimating the average number of commuters between any two locations per unit time. According to Barbosa et al. , research in this area has the potential to reveal the reasons that cause someone to work in a nearby or far away city and how one chooses a city to work or live in (see Figure 1). The state-of-the-art models used on human-mobility modeling assume that the number of people traveling between any two regions decreases linearly regarding the distance between them and is proportional to the size of the population of these regions [15, 16, 17, 13]. This assumption is not always true, as other factors related to urban systems can increase or decrease the human ﬂow; this is the case of underlying transportation networks , socioeconomic factors [11, 12, 19, 20], and traﬃc bottlenecks .
Along these lines, we propose a novel approach to quantify the ﬂow of people and reconstruct the network topology of human mobility through supervised machine learning algorithms of classiﬁcation and regression. These algorithms adapt at each iteration to learn from the data, which improves the prediction ability of the model, making the results more accurate. Both classiﬁers and regressors are based on the classical machine learning paradigm, according to which the machine uses features to learn a model able to predict the labels (classes) in a two-stage process: training and testing .We use yearly-updated urban indicators as features, which describe traits related to the quality of life and work in cities from the perspective of the economic, political, social, and environmental spheres . We draw our analysis on 45 urban indicators of 5,565 Brazilian municipalities and the daily number of people commuting between every city of our data set (see Figure 2). We demonstrate that, when compared to our approach, previous models have a lower performance in predicting unweighted links between two given cities and also in predicting weighted links. A weighted prediction means that, besides foreseeing the link between cities, it also predicts the number of commuters.
The model we propose, which relies on gradient-based machine learning algorithms, can predict the links of the commuter network with 90.4% of accuracy and weight these same links with 77.6% of the variance between the predicted and the observed ﬂow of people between cities. Moreover, we use SHapley Additive exPlanations  (SHAP) values to interpret the results of the machine learning model so to quantify the importance of each feature in the prediction task. Through this technique, it was possible to identify which are the most important features to describe the phenomenon of human mobility. We notice that not only is distance critical in shaping human mobility, but also other variables such as GDP and unemployment rate play important roles in this phenomenon.
The authors would like to thank Coordenação de Aperfeiçoamento de Pessoal de Nível Superior – Brazil (CAPES) – Finance Code 001; Fundaçõ de Amparo à Pesquisa do Estado de São Paulo (FAPESP), grants 2013/07375-0, 2014/253370, 2016/16987-7, 2016/17078-0, 2017/08376-0, and 2019/04461-9; Conselho Nacional de Desenvolvimento Cientíﬁco e Tecnológico (CNPq) grants 303694/20157, 404870/2016-3, 167967/2017-7, and 305580/2017-5; and Intel for their ﬁnancial support.