Code Monkey home page Code Monkey logo

crime-rate-forecasting-in-chicago's Introduction

Crime Prediction

I use the Crime data from Data Access Layer(DAL) https://github.com/cioc/DAL, which is a library that makes it easy to use the datasets.

For this project, I work with the Chicago Crime dataset. The area of Chicago is partitioned into N = 2,985 square regions, with centers in the form of key-value pairs of latitude and longitude. And I build up models and forecast for the following ten different crime types:

assault, battery, burglary, crimial damage, deceptive practice, motor vehicle theft, narotics, other offense, robbery, theft

The following bit of Python code shows how to extract and display them:

from DAL import create

# Create a handle to the crime dataset 
crime=create("crime")

# Gets the list of crime types.
crime.get_crime_list()

# Gets the dictionary of number of crimes in each region. The first tuple value in key is the region, the second tuple value in key is the crime type and the value is the number of crimes.
crime.get_crime_counts()

# Gets the dictionary of regions with it's latitude and longitude.
crime.get_region_list()

# Iterates over all crimes in the dataset with the data time , latitude, longitude and type of crimes.
crime.iter()

Kernel selection

I implement kernel smoothing to estimate a Poisson rate function parameter. To apply kernel smoothing, I experiment with different tuning parameters in Gaussian, Epanechinikov and Boxcar kernel. Then I select those producing the highest log-likelihood on held-out data.

Prediction of crime rates one week in advance

For each of type of crime, I save my predicted rate for the following week in a file, named as [crime-type].txt. With the predicted crimes rate in all regions and their geographical information, I could have generated heatmaps by heatmap.py, https://github.com/jjguy/heatmap. However, due to the premission to access the data for now, the heatmaps are missing. I will fix it as soon as I get the permission to access the data.

Please check the notebook here for detail:

http://nbviewer.ipython.org/github/eddieyue/Crime-rate-forecasting-in-Chicago/blob/master/Forecasting%20of%20Crimes%27%20location%20and%20rate%20in%20Chicago%20.ipynb

crime-rate-forecasting-in-chicago's People

Contributors

eddieyue avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.