Giter Site home page Giter Site logo

fblamanna / most-frequented-locations Goto Github PK

View Code? Open in Web Editor NEW

This project forked from maximelenormand/most-frequented-locations

2.0 1.0 0.0 18 KB

Extract Most Frequented Locations from individual spatio-temporal trajectories

License: GNU General Public License v3.0

Python 100.00%

most-frequented-locations's Introduction

Extract Most Frequented Locations from individual spatio-temporal trajectories

Copyright 2015 Maxime Lenormand. All rights reserved. Code under License GPLv3.


This script returns the location most frequented by an individual (called MFL) during daytime and nighttime according to a certain time window. The MFL during a given time windows is defined as the location in which the individual has spent most of his/her time. In this algorithm, two scales are considered, hours and days. Hopefully, for a given individual, the MFLs detected at the two scales should be the same.

Input

The algorithm takes as input a 6 columns csv file with column names, the value separator is a semicolon ";". Each row of the file represents a spatio-temporal position of an individual's trajectory. The time is given by the columns 2 to 5 (year, month, day and hour). It is important to note that the table should be SORTED by individual ID and time.

  1. ID of the individual
  2. Year
  3. Month
  4. Day
  5. Hour
  6. ID of the geographical location

Parameters

The algorithm has 6 parameters:

  1. wdinput: Path of the input file (ex: "input.csv")
  2. wdoutput: Path of the output file (ex: "outputoftheawsomemaximelenormandsalgorithm.csv")
  3. minH: Lower bound (included) of the night time window (ex: 20h)
  4. maxH: Upper bound (included) of the night time window (ex: 7h)
  5. minW: Lower bound (included) of the day time window (ex: 8h)
  6. maxW: Upper bound (included) of the day time window (ex: 19h)

Output

The algorithm returns a 15 columns csv file with column names, the value separator is a semicolon ";". Each row represents an individual:

  1. ID: ID of the individual
  2. NbMonths: Number of distinct months covered by the trajectory
  3. NbConsMonths: Maximum number of consecutive months covered by the trajectory
  4. MFLHomeDays: MFL during nighttime (day scale), 'NoMFL' if NbDaysHome=0
  5. MFLHomeDays2: Second MFL during nighttime (day scale) if ex aqueo, 'NoMFL' otherwise
  6. NbDaysHomeMFL: Number of distinct days (during nighttime) spent in the MFL
  7. NbDaysHome: Number of distinct days covered by the trajectory (during nighttime)
  8. MFLHomeHours: MFL during nighttime (hour scale), 'NoMFL' if NbHoursHome=0
  9. MFLHomeHours2: Second MFL during nighttime (hour scale) if ex aqueo, 'NoMFL' otherwise
  10. NbHoursHomeMFL: Number of distinct hours spent in the MFL (during nighttime)
  11. NbHoursHome: Number of distinct hours covered by the trajectory (during nighttime)
  12. MFLWorkDays: MFL during daytime (day scale), 'NoMFL' if NbDaysWork=0
  13. MFLWorkDays2: Second MFL during daytime (day scale) if ex aqueo, 'NoMFL' otherwise
  14. NbDaysWorkMFL: Number of distinct days spent in the MFL (during daytime)
  15. NbDaysWork: Number of distinct days covered by the trajectory (during daytime)
  16. MFLWorkHours: MFL during daytime (hour scale), 'NoMFL' if NbHoursWork=0
  17. MFLWorkHours2: Second MFL during daytime (hour scale) if ex aqueo, 'NoMFL' otherwise
  18. NbHoursWorkMFL: Number of distinct days spent in the MFL (during daytime)
  19. NbHoursWork: Number of distinct hours covered by the trajectory (during daytime)

Execution

You can run the code using the command:

python MFL.py 'input.csv' 'output.csv' 20 7 8 19

Citation

If you use this code, please cite:

Louail T, Lenormand M, Murillo Arias M & Ramasco JJ (2015) Crowdsourcing the Robin Hood effect in the city. Arxiv e-print, arXiv: .

If you need help, find a bug, want to give me advice or feedback, please contact me! You can reach me at maxime[at]ifisc.uib-csic.es

References

[1] Louail et al. (2015) Crowdsourcing the Robin Hood effect in the city.. Arxiv e-print, arXiv: .

most-frequented-locations's People

Contributors

maximelenormand avatar

Stargazers

Iacopo Iacopini avatar Fabio Lamanna avatar

Watchers

Fabio Lamanna avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.