Problem Introduction
In the Louisville, KY metro area, the frequency of firearm-related crimes has seemingly been increasing over the past several years. This study makes use of data provide by the Louisville Metro Police Department of Louisville, KY, and examine the potential impact of firearm-related crimes to Louisville businesses and their patrons. The goal of this work is to give businesses and their patrons useful knowledge concerning the frequency and trends of crimes involving firearms in their particular areas. Making reliable information available can prevent lost revenue due to public misperceptions about safety in areas of the Louisville Metro area.
Data
The Louisville Metro government maintains an open data portal that contains datasets provided by the Louisville Metro Police Department concerning crime statistics. One of these datasets is a distillation from a larger dataset into one that is firearm-specific. The particular file used, Firearms Intake, contains data from crimes where a firearm of some type was confiscated. The data covers January 2010 through most of February 2017.
The original dataset contains 10871 rows, includes street addresses, zip codes, GPS coordinates, and date information. Crimes involving firearms, except for suicides and regular death investigations, are most often serious and involve violence. For this reason, all the crime categories in the dataset are included in the analysis.
The firearm-related crime dataset is used in conjunction with the geocoordinates of Louisville zip codes. The Foursquare's Places API was used to collect information about the venues present in the zip codes of the crime dataset. The geocentric coordinates for the Louisville zip codes were put into the file louisvillezips.csv. The zip code coordinates are used for displaying the aggregated results for each zip code.
The Foursquare venue data was collected and saved into a file to economize on the number of API calls. A Foursquare query was done for the list of venues within 10 miles of Louisville's geocoordinates. A total of 79 venues were returned, and the details of each venue saved in the data file.
Links for viewing the Jupyter notebooks that used the Foursquare API to create the venue data file and the primary Jupyter notebook for the analysis are given in the Resource section.
Methodology
The Firearms Intake data was initially 10871 rows but after initially dropping rows with na values the total number of rows was 8904. This drop in the number of rows was primarily from incidents that involved usual death investigations or suicides, in which many columns in the dataset wind up with na values.
After the data cleansing, the recovery data column of the data was used to generate another column in the dataset representing the day of the week of the recovery data with Monday having a value of 1 and Sunday a value of 7.
The firearm data was used to make a time series plot to show if, in fact, there is a reason to believe that the number of gun-related crimes is increasing in the Louisville Metro area. There was negligible data for the years before 2010, so the data for the time series plot starts with 2010. To make the plot easier to read, LOESS smoothing of 15% was applied to the data.
A Folium map with the locations of the Louisville zip codes and a random sampling of size 10 from the Foursquare detailed venue dataset displayed was created. The map is centered on Louisville. The radius of the circle markers on the map are drawn to reflect the number of firearm-related crimes. The map is interactive. If a zip code is selected, the pop-up shows the percent of crimes over the years 2010 to 2017 that occurred in the zip code and the percentage of the crimes by day of the week is displayed. If a venue is selected, its name, Foursquare rating, category, and zip code information is displayed.