scikit-mobility: an open-source Python library for human mobility analysis and simulation

Luca Pappalardo, Gianni Barlacchi, Filippo Simini, Roberto Pellungrini

Abstract

As urban environments become increasingly data-rich and hyper-connected, the demand for sophisticated human mobility analysis has grown across disciplines ranging from urban planning to epidemic control. Historically, this field has suffered from fragmentation, with researchers relying on disparate, custom-built tools. scikit-mobility addresses this gap by providing a comprehensive, open-source Python library that integrates geo-spatial data processing, mobility metric calculation, and state-of-the-art simulation models into a single, standardized pipeline.

Introduction

Understanding how individuals and populations move through space and time is critical for managing modern infrastructure, optimizing traffic flow, and responding to public health crises. However, the lack of a unified computational framework has often forced researchers to reinvent the wheel, implementing classic models like the Gravity model or individual-based simulations like Exploration and Preferential Return (EPR) from scratch.

scikit-mobility is designed to be the "one-stop shop" for mobility science. By adopting the design philosophy of the popular scikit ecosystem, it lowers the barrier to entry for data scientists and researchers, moving mobility analysis from niche computational physics into the mainstream Python data science stack.

Library Architecture and Methodology

The library is built upon the foundational Python libraries numpy, pandas, and geopandas. This ensures that users can leverage familiar data structures while performing complex spatial joins and temporal filtering. The functionality of scikit-mobility is organized into three primary pillars:

1. Analysis

The library implements a wide array of standard measures to characterize mobility patterns. These include:

  • Radius of Gyration: Measuring the typical distance an individual travels.
  • Mobility Entropy: Quantifying the predictability of movement patterns.
  • Origin-Destination (OD) Matrices: Summarizing the flow of individuals between specific geographic regions.

2. Simulation

Simulation is the core strength of scikit-mobility, supporting modeling at two distinct scales:

  • Collective Models: These models generate macro-level fluxes between locations. The library includes the classic Gravity model (dating back to Zipf) and the more modern Radiation model, which accounts for job opportunities and population density.
  • Individual Models: These generate synthetic spatio-temporal trajectories for specific agents. The library supports the EPR model and its variants (s-EPR, r-EPR), as well as sophisticated generative frameworks like DITRAS and TimeGeo.

3. Validation

To ensure that simulated data accurately reflects reality, the library provides a suite of validation metrics. These tools allow researchers to compare synthetic trajectories against real-world benchmarks, ensuring the statistical properties of the generated data are robust.

Data Integration and Privacy

scikit-mobility is designed to ingest diverse geo-spatial datasets, including GPS traces from mobile devices, Call Detail Records (CDRs) from telecommunications providers, and geo-tagged social media posts. A significant advantage of the library’s generative power is its contribution to privacy-preserving research. By using models like DITRAS to create highly realistic synthetic populations, researchers can share and analyze mobility data without compromising the sensitive personal information found in raw GPS logs.

Key Insights and Impact

The primary contribution of scikit-mobility is the successful integration of decades of mobility research—spanning from 1940s-era models to 2016-era frameworks—into a single, accessible tool. Its "scikit"-style API allows for seamless "what-if" analysis. For example, urban planners can simulate how mobility might shift following the construction of new infrastructure, or epidemiologists can model the potential spread of a virus based on current movement trends.

Limitations and Future Directions

While scikit-mobility provides a robust foundation, the authors acknowledge areas for future growth. Currently, the library relies on the standard pandas and numpy stack, which may face challenges when scaling to "Big Data" scenarios involving billions of GPS pings. Future iterations may explore distributed computing integrations to handle larger datasets. Additionally, the authors envision the library evolving to support even more complex urban simulations, particularly those involving traumatic events like international crises or large-scale public health emergencies.

Conclusion

scikit-mobility represents a significant step forward in standardizing human mobility research. By providing a unified, open-source framework for analysis and simulation, it empowers a broader community of researchers and practitioners to tackle the complex challenges of our increasingly mobile world.

Summary updated

BibTeX
@article{pappalardo2019scikit,
  author = {Luca Pappalardo and Gianni Barlacchi and Filippo Simini and Roberto Pellungrini},
  title = {{scikit-mobility: an open-source Python library for human mobility analysis and simulation}},
  journal = {J. Stat. Softw.},
  year = {2019},
}
Figure