The City and County of San Francisco had launched an official open data portal called SF OpenData in 2009 as a product of its official open data program, DataSF. The portal contains hundreds of city datasets for use by developers, analysts, residents and more. Under the category of Public Safety, the portal contains the list of SFPD Incidents since Jan 1, 2003.
In Part 1 of this series of analysis, I performed an exploratory time-series analysis on the crime incidents data to identify any patterns.
In Part 2 of this series, I performed an exploratory geo analysis on the crime incidents data based on the San Francisco Police Department District classification to identify any patterns.
In this Part 3, I have performed an exploratory analysis on the crime incidents based on the category of the crime.
The data for this analysis has been downloaded from the publicly available data from the City and County of San Francisco’s OpenData website SF OpenData. The crime incidents database has data recorded from the year 2003 till date. I downloaded the full data and performed my analysis for the time period from 2003 to 2015, filtering out the data from the year 2016. There are nearly 1.9 million crime incidents in this dataset.
I have performed minimal data processing on the downloaded raw data to facilitate my analysis.
Data source location: https://data.sfgov.org/data
Number of crime incidents processed: 1,859,850
The SFPD categorizes all the crimes happening in its Police Districts under one of the following 39 categories.
The following plot depicts the number of crimes recorded from the year 2003 till the end of the year 2015 ordered by the category of the crime. By analyzing the plot above, we can clearly see that “Larceny/Theft” has been the most commonly occurring crime followed by “Other Offenses” and “Non-Criminal” crimes. Since these two categories are very generic, we cannot get much insight about these crimes. “Assault”, “Vehicle Theft”, “Drug/Narcotic” and “Vandalism” also occur in high numbers.
The following plot depicts the trend of the top 10 category of crimes from the year 2003 till the end of the year 2015.By analyzing the trends in the plot above we can arrive at the following key insights:
The following plot depicts the top 10 category of crimes in various Police Districts.By analyzing the plot above, we can arrive at the following insights:
The above is just a high-level exploratory analysis. With further in-depth analysis it is possible to arrive at more insights. In my future posts I will try to perform those analyses.
This analysis was performed entirely using RStudio version 0.99 and R Version 3.2.0.
The data processing and plots were done using the R libraries ggplot2 and dplyr.