Crime Prediction¶

Motivation:¶

A friend of mine who is a Psych major relayed that there is a correlation between heat and car accidents. I was curious whether there was correlation between crime in general and weather. If you can use weather to predict crime rates, places may be able to prepare with a larger law enforcement presence when needed.

Solution¶

I will use the heatindex column, humid column and interpers violence column to try and see if there is correlation between the weather and crime. I will plot two visualizations to see if there seems to be a trend in either higher/lower heat index or humidity and crime.

Impact¶

If there is strong correlation, being able to predict days where crime will be more rampant is useful to law enforcers, and they could use this data to see when more field workers/first responders are needed.

In [8]:
import pandas as pd
import pandas as pd
df = pd.read_csv ('Heat_Index_Crime.csv')
df
Out[8]:
date year month number_month day number_day interpersviolence homicides maxtemp humid precipitations windspeed moonlight holidays weekends fines vehicles heatindex
0 1/1/2010 2010 January 1 Friday 1 31 2 33 78 0.0 15.4 1.0000 1 0 2 0 26.2516
1 1/2/2010 2010 January 1 Saturday 2 6 0 32 82 0.0 16.5 0.9870 0 1 13 0 30.4034
2 1/3/2010 2010 January 1 Sunday 3 8 1 32 76 0.0 14.8 0.9440 0 1 11 0 29.7769
3 1/4/2010 2010 January 1 Monday 4 7 0 34 81 0.0 10.7 0.8760 0 0 0 13 30.0638
4 1/5/2010 2010 January 1 Tuesday 5 3 2 35 83 0.0 13.5 0.7870 0 0 0 1 30.0271
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2552 12/27/2016 2016 December 12 Tuesday 27 7 0 31 75 0.0 19.3 0.0602 0 0 0 60 30.0698
2553 12/28/2016 2016 December 12 Wednesday 28 5 3 31 79 0.0 14.1 0.0229 0 0 0 81 29.3975
2554 12/29/2016 2016 December 12 Thursday 29 11 0 31 79 0.0 23.0 0.0030 0 0 0 209 30.0530
2555 12/30/2016 2016 December 12 Friday 30 4 1 32 83 0.0 18.5 0.0019 0 0 4 21 29.3132
2556 12/31/2016 2016 December 12 Saturday 31 4 1 33 82 0.0 13.8 0.0203 0 1 18 0 32.4591

2557 rows × 18 columns

Dataset:¶

  • date
  • year
  • month
  • day of week
  • number day tracked
  • cases of interpers violence
  • number of homicides
  • max temperature
  • humidity
  • precipitation
  • windspeed
  • moonlight
  • holidays (1 if yes, 0 if no)
  • weekends (1 if yes, 0 if no)
  • fines
  • vehicle accidents
  • heatindex

Potential Issues¶

Obviously, other factors play an effect on crime. For example, there might be more violence on January 1st as this is New Years, and typically a holiday where many are under the influence. The table does show if a day is a holiday, which could help explain some outliers, if they occur, but other instances not shown, like maybe a protest, could lead to unexplained outliers.