Spatial methods for crime prediction

Allan Quadros

Quynh Do

Department of Statistics

Introduction

  • The benefits of analyzing crime data and predicting crime incidents are clear

  • Crimes are often repeated under the same circumstances \(\Rightarrow\) suitable data for predictive analysis

  • We analyzed two papers:

    • “Predicting Crime Using Spatial Features” (Khanam Bappee, Soares Junior, and Matwin (2018)).

    • “Crime Prediction & Monitoring Framework Based on Spatial Analysis” (ToppiReddy, Saini, and Mahajan (2018))




Paper 1 - “Predicting Crime Using Spatial Features”

PAPER 1 - Proposal


  • feature engineering to enhance the accuracy of classification models/algorithms applied to crime data

  • 2 new features that would allow a more accurate classification of the type of crime occurred at a specific location:

    • geocoding:
      • linking addresses to types of location using a catalog
    • creation of hotspots:
      • using HDBSCAN \(\Rightarrow\) keep the shortest distance between the new crime record and the clusters’ centroids

PAPER 1 - (H)DBSCAN

  • One of the advantages of HDBSCAN over DBSCAN is that the former does not need parameter \(\epsilon\)

PAPER 1 - Proposal Visualization

PAPER 1 - Data


  • 2 types of dataset (both from Halifax police department - Nova Scotia, CAN):

      1. without the proposed features
      • geographic location, incident_start_time, month, weekday, ucr_desriptions (the response variable)
      1. with the proposed features
      • (1) + geocoding + distance to the nearest hotspot

(***) Response variable labels: Alcohol-related, Assault, Property damage, Motor vehicle

PAPER 1 - Methods

  • Classifiers:
    • Logistic Regression, Random Forest, SVM, and Ensemble

    • + 10-fold cross validation

  • Metrics:
    • accuracy
    • AUC
  • t-test (matched pairs)
    • evaluate whether the differences were statistically significant

PAPER 1 - Results

Accuracy

LR
RF
SVM
Ensemble
Crime type raw eng raw eng raw eng raw eng
Alcohol-related 59.36 65.27 57.73 73.51 59.28 71.31 58.61 75.52
Assault 65.35 65.03* 47.94 58.89 63.53 65.27 55.96 64.41
Property damage 88.43 88.41* 84.03 88.57 88.19 88.43 88.43 88.44*
Motor vehicle 81.59 82.31 71.82 81.11 81.11 81.45 81.56 81.80*

AUC

LR
RF
SVM
Ensemble
Crime type raw eng raw eng raw eng raw eng
Alcohol-related 0.575 0.723 0.649 0.818 0.635 0.747 0.661 0.825
Assault 0.528 0.613 0.457 0.545 0.504 .533* 0.459 0.567
Property damage 0.519 0.651 0.531 0.646 0.501 .505* 0.534 0.657
Motor vehicle 0.515 0.686 0.488 0.682 0.494 0.536 0.490 0.694




Paper 2 - “Crime Prediction & Monitoring Framework Based on Spatial Analysis”

PAPER 2 - Proposal



  • Predict crimes using data mining techniques and theories from criminology such as Rational Choice Theory and Routine Activity Theory.

PAPER 2 - Data


  • Dataset obtained from UK police department website (data from 2015-17)

    • 5 relevant attributes for crime prediction: crime type, locAtion, date, latitude, and longitude
  • Data was preprocessed with removal of inconsistent data, and transforming data for prediction

PAPER 2 - Data Visualization (1)

Module 1 displays recent crime data on Google Maps, allowing individuals to identify risky areas and law enforcement to improve security.

Module 2 shows the exact location of the crime in a 3D view, helping analysts to investigate without visiting the location repeatedly.

PAPER 2 - Data Visualization (2)

Module 3 displays crime types in different areas, helping law enforcement to analyze frequently occurring crimes and improve security measures.

Module 4 shows crime hotspots with high crime density, which is useful for researchers and analysts to examine the occurrence of hotspots in certain areas.

PAPER 2 - Data Visualization (3)

Module 5 generates a crime frequency report based on monthly occurrences and crime categories.

Module 6 uses graphs and bar charts to show the trend of different types of crimes over time.

PAPER 2 - Methods



  • 2 classifiers:

    • k-NN

    • Naïve Bayes

PAPER 2 - kNN (1)

k-NN is a way to group things based on their similarities. It works by looking at the things closest to the one you’re trying to classify and assigning it to the group that has the most similar things. This can be used to predict where crimes are likely to happen base on where they’ve happened before. It takes into account location and date, and computes the distance between different areas to group them together.

PAPER 2 - kNN (2)

First step, compute the distances between a test instance and all training instances

For this, the latitude, longitude and the number of days as the coordinates and compute the distance factor as

\(d_i = \sqrt{(x_i - \bar{x})^2 + (y_i - \bar{y})^2}\), \(d_i = \sqrt{(x_i - \bar{x})^2 + (y_i - \bar{y})^2 + (Z_i)^2}\)

To avoid the squaring and square root, the Manhattan distance was computed

\[ d_i = |x_i - x| + |y_i - \textbf{1}| + |z_i|\]

PAPER 2 - kNN (3)

The next step is to identify the k-nearest neighbors to the test instance based on their distances. The value of k is a pre-defined parameter in the K-NN algorithm, and it determines the number of nearest neighbors to be considered for classification.

latitude longitude
53.74933 -2.000177
52.85565 -2.799866
53.98675 -2.548269
53.97359 -2.828916
53.72188 -2.161456
53.84521 -2.546358
52.12237 -2.252581
52.25856 -2.534608

PAPER 2 - kNN (4)

Their corresponding class labels (i.e., types of crime) are used to determine the class membership of the test instance. The class membership is determined by taking a majority vote of the k-nearest neighbors. This means that the class label assigned to the test instance is the one that occurs most frequently among its k-nearest neighbors.

latitude longitude prediction probability textAddress
53.74933 -2.000177 Drugs 0.67 Walker Ln, Hebden Bridge HX7, UK
52.85565 -2.799866 Shoplifting 0.40 B4397, Shrewsburry SY4 5ST, UK
53.98675 -2.548269 Shoplifting 0.40 Whitendale Road, Clitheroe BB7 3BL, UK
53.97359 -2.828916 Shoplifting 0.40 Hillam Ln, Lancaster LA2 0DX, UK
53.72188 -2.161456 Shoplifting 0.67 Dark Red, Todmorden OL14 7ER, UK
53.84521 -2.546358 Shoplifting 0.40 NA
52.12237 -2.252581 Criminal damage and arson 0.67 115 B4424, Callow End, Worcester WR2 4TH, UK
52.25856 -2.534608 Shoplifting 0.40 Bromyard Rd, Tenbury Wells WR15, UK

PAPER 2 - Naïve Bayes (1)

based on Bayes theorem which describes the probability of an event based on the prior knowledge of conditions that might be related to the event.

\[\operatorname{Pr}(h|x) = \frac{\operatorname{Pr}(x|h) \operatorname{Pr}(h)}{\operatorname{Pr}(x)}\]

The Naïve Bayes classifier classifies a new instance X by assigning the most probable target value i.e. the maximum likelihood. i.e. 

\[\max_{d_i \epsilon d} \operatorname{Pr}(d_i) \prod_{k=1}^n \operatorname{Pr}\left(\frac{x_k}{d_i}\right)\]

PAPER 2 - Naïve Bayes (2)

  • Naive Bayes can classify crime types by calculating the conditional probabilities of each attribute given each class.
  • The model is trained using a crime dataset, and once trained, can predict the class of a new instance based on its attributes.
  • The classifier calculates the posterior probability of each class given the attribute values and assigns the class with the highest probability as the predicted class.

PAPER 2 - Naïve Bayes (3)

crime probability
Anti-social behaviour 0.3750000
Criminal damage and arson 0.1607143
Violence and sexual offences 0.1071429
Burgarly 0.1071429
Shoplifting 0.0892857
Other theft 0.0712857
Drugs 0.0357143
Public order 0.0357143
Vehicle crime 0.0178571
Bycicle theft 0.0000000
Other crime 0.0000000
Robbery 0.0000000
Possession of weapons 0.0000000
Theft from the person 0.0000000




Thank you!