This Python program uses a nearest neighbor algorithm to determine whether building inspectors visited a target site the day they were assigned the inspection. It uses two datasets: the route sheet of sites they were assigned to inspect and data from the inspector's smart phone that periodically sends latitude and longitude coordinates to Verizon's Field Force Management database.
The program implements these steps:
- Imports data into a pandas data frame and automatically cleans the data.
- Places a 500 foot radius (a geofence) around the building that is on the route sheet (the building that is to be inspected).
- Calculates the closest point that the inspector came to the location.
- If the inspector enters the geofence of the target building (is within 500 feet of the center of the building), the inspection site is classified as inspected, if not in geofence, the inspection site is classified as not inspected.
- Calculate the inspector’s closest distance and address to the target building.
- Determine the location of the inspector if not at the inspection site.
- If the phone has a signal drop and inspector does not enter geofence, determine if inspector went to the inspection site using path analysis (see example below).
A map produced in Tableau showing results of perfect match (inspector went to all of the sites), Blue = DOB Inspection Site Orange = FFM Data
Example of a no match, FFM data shows that inspector did not go to inspection site:
Example of match using path analysis, this method is useful when phone signal randomly drops off, the inspection site is classified as a "No" visit, but exists on the path so reclassified as a visit: