GithubHelp home page GithubHelp logo

waynnbz / patient-clinic-proximity-finder Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 66 KB

Find the nearest travel distance clinic for each patient. Mainly used Google Geocode and Distance Matrix APIs

Python 37.73% Jupyter Notebook 62.27%

patient-clinic-proximity-finder's Introduction

Final design

  • Let's do two approaches

    1. Pure Google
      • Using Google Geocoding API to obtain lat/lng
      • Using geopy.distance.geodesic to filter the clinic into N nearest ones in terms of geodesic distance (N=5/6 suggested after explore the clinic distribution on map
      • Finally using Google distance matrix API to get the shortest travel distance for the N clinics and output the nearest one
    2. Possibly free:
      • Geocode.ca throttled port for lat/lng
        • (tested to be more accurate than Google but throttle control applies in free port)
      • Same N pool processs using geodesic distance
      • Use OSMnx to gain a node/edge a graph centered at Patient node with a radius by considering N pool dist range
      • Finally using Networkx to compute the shortest path locally from the OSMnx graph
  • Geocode detection failed case

    • Shouldn't break the code and still should be able to recommend clinics
      • 'Postal Code' < 'FSA' < 'City' < 'Province'
  • Retry on failure:

    # To retry because intermittent failures sometimes occurs
    except (GeocoderQueryError) as error:
        if retry_counter < RETRY_COUNTER_CONST:
            return geocode_address(geo_locator, line_address, component_restrictions, retry_counter + 1)
        else:
            location_result = {"Lat": 0, "Long": 0, "Error": error.message, "formatted_address": "",
                               "location_type": ""}
  • During geocoding process, the will run through the fallback schema list recursively if best address failed, and in worst case scenario fall back to default values set in config file

  • I've switched to the Google geocoder as Nominatim is pretty sensitive to missing information, Google hammers through it no problem

  • 'Postal Code' fail rate: 3/100 for C_df

    • however, all 3 failed cases are later correctly geocoded after adding a component filter country:CA
      • One building offset, comparing the result from component added failed case to its physical address
    • TYPO, there's typo case (eg. V3Z 6S7 which mapped to V3S 6S7)
      • By adding physical 'address' GoogleV3 still able to figure out the correct address
      • Strangely enough, V3Z 6S7 is able to find a locale from OSM Geocoder.CA (and all other failed GoogleV3 case), same locale as from Google but labeled as input V3Z 6S7. Maybe the typo is from Google???
      • I guess this proves that Geocoder.CA is more accurate than GoogleV3 (w/ country component set to Canada)
  • 'Address' alone fail rate 11/100 (expected)

    • However, with country component filtering, the failed cases only reduced 1, yields 10/100
  • Cost and rate limit:

    • for 0-100,000: $0.005 per each
    • 50 request per second(QPS)

patient-clinic-proximity-finder's People

Contributors

waynnbz avatar

Watchers

 avatar  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.