Skip to content
RaspBary: Hawkes Point Process Wasserstein Barycenters as a Service
Python HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

RaspBary: Hawkes Point Process Wasserstein Barycenters as a Service

Real-time Allocation Service with Point process BARYcenters

We have developed a clustering and prediction method that forms the back end of an app designed with the Indianapolis EMS department to decrease their overall response time to medical emergencies. Our method uses an online Hawkes process estimation algorithm to model and predict the probability of medical events in specified grid cells. We use calculations of Wasserstein Barycenters to place ambulances in optimal locations during predicted peak event times. Our method is extendable to other spatial-temporal processes and available as an API for public use.



  • Requirements: Runs on Python 3
  • Clone to your local repository


Point Process

  • Begin by loading in correctly data in format of Pandas dataframe with labels of DATE_TIME: datetime string,'%Y-%m-%d %H:%M:%S' (or UNIX timestamp), XCOORD: longitude coordinate, YCOORD: latitude coordinate. Then train the model.
    • See our Wiki page for more information on initialization. In particular the min/max coordinates and track_granularity may need to be altered.
    • alt text
  • After training, param_examine() suggests parameters to examine for evaluating convergence of Hawkes process values as well as variance of day and hour probability vectors used to add periodic trends to the model.
    • alt text
  • Use hotspot_examine() to assess whether the trained model's intensity values produce a reasonable amount of events in reasonable grid locations. (This is not a prediction, just a comparison to data points used for training.)
    • alt text
  • Initialize PointProcessRun class and run a test prediction.
    • alt text
  • Update PointProcessRun with dataframe containing labels DATE_TIME: datetime string,'%Y-%m-%d %H:%M:%S' (or UNIX timestamp), XCOORD: longitude coordinate, YCOORD: latitude coordinate.
    • alt text
  • Predictions can be generated through the following methods.
    • alt text
  • Locations for Wasserstein clustering can also be generated.
    • alt text


  • Here is an example of Wasserstein clustering using locations passed in from PointProcessRun class:

    • alt_text
  • Running Wasserstein over predicted intensities yields results shuch as this:

    • alt_txt

API Usage

  • We have configured our code to run on Amazon Web Services.
  • NOTE: timestamps will be converted to UTC.
  • This is the main idea:
    • alt text
Intensity Projections
  • The 2 required query parameters are the following: "start_time" and "interval_count". "start_time" is a timestamp formated time to start the point intensity prediction. "interval_count" is the amount of 15 minute intervals to predict. This request will return the 70 by 50 grid of point intensites (3500 points per "interval_count"). An example URL string will yeild the following results:
    • URL: https://server_address/emergencies?start_time=1485798259&interval_count=1
    • alt_txt

Vehicle Locations

  • Utilizing the post request is easy to use in Postman. Here you will need to send in a json file of the current truck locations. The Postman environment should look like this:
    • alt_txt
  • The "start_time" parameter will specify when the point process will predict point intensities. This trucks will allocate over this data. "interval_count" determines the length of time to predict while "interval_time" sets the length of each interval (NOTE: this parameter is ignored and the default 15 will always be used). For the current truck positions, "trucks" contains a list of each trucks' geographical location. The "virtual" parameter determines if the truck is allocatable.
  • Sending the POST request will yeild results like this:
    • alt_txt
  • This returns a list of objects called "TruckSchema." Each object has the current location and the assigned location.

Update Model

CSV Upload
  • The model can be updated through CSV upload using the login.html file.
  • Simply load the correctly formatted CSV:
    • alt_txt
  • The model can also be updated through a get request with URL string parameters xcoord (longitude), ycoord (latitude) and unix timestamp.
  • Example URL: http://server_address/SingleProcessUpdate?xcoord=-86.43&ycoord=39.14&timestamp=1532959162.


  • marches
  • rjhosler


  • Mohler, George, and P. Jeffrey Brantingham. “Privacy Preserving, Crowd Sourced Crime Hawkes Processes.” 2018 International Workshop on Social Sensing (SocialSens), 28 May 2018, doi:10.1109/socialsens.2018.00016.
  • Cuturi, Marco, and Arnaud Doucet. “Fast Computation of Wasserstein Barycenters.” Proceedings of the 31st International Conference on Machine Learning, JMLR W&CP 32 (2) 2014, 14 June 2014, doi:arXiv:1310.4375v3 [stat.ML] .


You can’t perform that action at this time.