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

Data source: https://data.sfgov.org/Public-Safety/SFPD-Incidents-from-1-January-...

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:

- There has been a steep increase in “Larceny/Theft” since 2011.
- There has been a steep decline in “Vehicle Theft” since 2006 and has remained more or less at the same level since then.
- “Drug/Narcotic” related crimes had peaked in 2009, but have declined since then.

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:

- As highlighted in red in the plot above, “Larceny/Theft” is the most common crime across the Police Districts with the exception of Bayview, Ingleside, Mission and Tenderloin.
- The most common crime in Tenderloin is related to “Drug/Narcotic”.

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.

© 2019 Data Science Central ® Powered by

Badges | Report an Issue | Privacy Policy | Terms of Service

**Most Popular Content on DSC**

To not miss this type of content in the future, subscribe to our newsletter.

**Technical**

- Free Books and Resources for DSC Members
- Learn Machine Learning Coding Basics in a weekend
- New Machine Learning Cheat Sheet | Old one
- Advanced Machine Learning with Basic Excel
- 12 Algorithms Every Data Scientist Should Know
- Hitchhiker's Guide to Data Science, Machine Learning, R, Python
- Visualizations: Comparing Tableau, SPSS, R, Excel, Matlab, JS, Pyth...
- How to Automatically Determine the Number of Clusters in your Data
- New Perspectives on Statistical Distributions and Deep Learning
- Fascinating New Results in the Theory of Randomness
- Long-range Correlations in Time Series: Modeling, Testing, Case Study
- Fast Combinatorial Feature Selection with New Definition of Predict...
- 10 types of regressions. Which one to use?
- 40 Techniques Used by Data Scientists
- 15 Deep Learning Tutorials
- R: a survival guide to data science with R

**Non Technical**

- Advanced Analytic Platforms - Incumbents Fall - Challengers Rise
- Difference between ML, Data Science, AI, Deep Learning, and Statistics
- How to Become a Data Scientist - On your own
- 16 analytic disciplines compared to data science
- Six categories of Data Scientists
- 21 data science systems used by Amazon to operate its business
- 24 Uses of Statistical Modeling
- 33 unusual problems that can be solved with data science
- 22 Differences Between Junior and Senior Data Scientists
- Why You Should be a Data Science Generalist - and How to Become One
- Becoming a Billionaire Data Scientist vs Struggling to Get a $100k Job
- Why do people with no experience want to become data scientists?

**Articles from top bloggers**

- Kirk Borne | Stephanie Glen | Vincent Granville
- Ajit Jaokar | Ronald van Loon | Bernard Marr
- Steve Miller | Bill Schmarzo | Bill Vorhies

**Other popular resources**

- Comprehensive Repository of Data Science and ML Resources
- Statistical Concepts Explained in Simple English
- Machine Learning Concepts Explained in One Picture
- 100 Data Science Interview Questions and Answers
- Cheat Sheets | Curated Articles | Search | Jobs | Courses
- Post a Blog | Forum Questions | Books | Salaries | News

**Archives**: 2008-2014 | 2015-2016 | 2017-2019 | Book 1 | Book 2 | More

**Most popular articles**

- Free Book and Resources for DSC Members
- New Perspectives on Statistical Distributions and Deep Learning
- Time series, Growth Modeling and Data Science Wizardy
- Statistical Concepts Explained in Simple English
- Machine Learning Concepts Explained in One Picture
- Comprehensive Repository of Data Science and ML Resources
- Advanced Machine Learning with Basic Excel
- Difference between ML, Data Science, AI, Deep Learning, and Statistics
- Selected Business Analytics, Data Science and ML articles
- How to Automatically Determine the Number of Clusters in your Data
- Fascinating New Results in the Theory of Randomness
- Hire a Data Scientist | Search DSC | Find a Job
- Post a Blog | Forum Questions

## You need to be a member of Data Science Central to add comments!

Join Data Science Central