Coder Social home page Coder Social logo

dssg / 411-on-311 Goto Github PK

View Code? Open in Web Editor NEW
44.0 136.0 42.0 99.18 MB

Exploratory analysis and predictive models of how Chicago's neighborhoods interact with the City's 311 service requests.

Home Page: dssg.io/projects#311

Python 69.66% R 30.34%

411-on-311's Introduction

Predictive analytics for smarter city services

Exploratory analysis and predictive models of how Chicago's neighborhoods interact with the City's 311 service requests.

This is project is a part of the 2013 Data Science for Social Good fellowship, in partnership with City of Chicago and the Chapin Hall at the University of Chicago.

The Problem: understanding Chicago through 311, predicting 311 through Chicago

Through the City of Chicago's 311 system, every Chicagoan can ask for city services, from graffiti removal to pothole filling to abandoned car removal. The 311 data these service requests produce reflect - albeit imperfectly - the needs of the city and its inhabitants.

We want to investigate how patterns of service requests are related to the social and economic makeup of Chicago's neighborhoods. Specifically, we want to answer two related questions:

  • What do service requests tell us about the different neighborhoods in Chicago?
  • Can we use a neighborhood's characteristics to predict future service requests volumes across the city?

Read more about 311 in Chicago in our wiki.

The Solution: exploratory analysis, k-means clustering, poisson regression

To answer those big questions, we performed a three-step analysis:

  1. Exploratory analysis of service request data through visualization of time series and scatterplots
  2. Applied k-means clustering, an unsupervised machine learning technique, to identify Chicago census tracts with similar service request patterns. This part of the analysis revealed clear clusters of census tracts that request 311 service in similar ways. These service-request clusters also tend to be geographically next to each other, and overlap with Chicago's race boundaries - a clear sign that Chicago's neighborhoods request services in distinct ways.
  3. Built statistical models to predict 311 requests levels across census tracts. We trained a Poisson Generalized Linear Models (GLM) on relevant demographic, economic, and temporal predictors. We fitted Poisson GLM for graffiti removals pothole fillings, but the code is easily customized to work with other service request types. These predictive models could eventually be used to make the City's public services more proactive and responsive to street problems.

Read more about exploratory analysis, clustering, and statistical models in our wiki.

The Data: 311 service requests and census data

We used the main data sources:

  1. Open 311 data from the City of Chicago open data portal. The City publishes to most popular service requests as open data, but only for the last few years.
  2. A database of 311 requests obtained from Chapin Hall. This dataset is an extract of the City's 311 system - it contains every service request type (there are hundreds) and goes back to when the 311 system was launched in 1999.
  3. 2010 Census and ACS (American Community Survey) data.

Read more about the data we used in our wiki.

Project layout

Data preparation

The folder munging contains some Python and R code that retrieves and preprocesses the data, aggregating it according to some specified spatial and temporal resolution (e.g. by Community Area, monthly.)

Exploratory analysis

The code that implements our exploratory analysis lives in the analysis/viz folder. It's a set of functions that operates on 311 service request data from the City of Chicago open data portal. Most of this analysis is performed at the level of community areas.

Clustering

The folder analysis/clustering contains code that applies the k-means clustering algorithm on a highly-dimensional space of 311 requests, aggregated by census tract. It uses the scikit-learn machine learning Python library.

sci-kit-learn

Predictive model

The code that implements our predictive models for graffiti removal and pothole filling requests is contained in the folder analysis/prediction. This part of the project is implemented in R.

Installation guide

The project consists of Python scripts and modules, and R scripts.

  • To execute Python scripts, install Python 2.7.x on your computer, and call the invoke directly or within a Python interpreter (we recommend iPython.)
  • To use Python modules (such as analysis/viz/viz_311_data.py), import the module within a Python file or a Python interpreter and call the functions.
  • To execute R scripts, install R and invoke the script directly or within the R interpreter. For editing and exploring the workspace, we recommend the RStudio IDE.

Some external libraries are needed:

Team

311 team

Contributing to the Project

License

Copyright (C) 2013 Data Science for Social Good Fellowship at the University of Chicago

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

411-on-311's People

Contributors

apanella avatar edjoesu avatar jauerbach avatar jlewis91 avatar jpvelez avatar sarahadelaide avatar zseeskin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

411-on-311's Issues

Wiki Documentation

REQUIRED WIKI SECTIONS

  • Homepage

    Intro: have a sentence or two about the project: the problems its solving, the partner, and how you're solving it. Also say that "this wiki is the central place to learn about the social problem we worked on, the data we used, the methods we used to solve it, and our findings" so people know what they're looking at.
    List of pages in the wiki

  • Problem

    An in-depth description of the problem your organization, the problem you're trying to solve, and any relevant domain knowledge. Feel free to copy from blog posts and posters, if relevant.

  • Data

    Describe the dataset(s) you used in the project as well as your database. Walk people through the data model (tables are handy for this), and include a (fake) sample of each dataset.
    If you scraped data, this is the place to document that.

  • Methodology

    An in-depth, technical write up of the method(s) you used on your projects. Use latex equation, walk people through algorithms and models, link out to relevant documentation when possible.

  • Results

    Discuss what metrics you're using to evaluate performance (if applicable), and what your final findings where.

  • Future work

    Discuss what you would like to do / what is in progress.

OPTIONAL WIKI SECTIONS - if its fits your project

  • Analysis

    If you did exploratory data analysis, this is the place to put it and explain your findings. Explain each finding and what your learned from it / how it motivated the methods you used. Put this between the "Data" and "Methodology" sections. Feel free to lift content from relevant blog posts, if any.

  • Resources

    Resources for domain knowledge, methods, and tech. Whatever pieces of paper you used to learn what you know.

  • Tool

    • API Documentation
    • Web app Documenation

Label ACS Variables to make usable for analysis

I now have a data extract from the Data Ferrett with both census tract and block group level data. Plan is to adapt Nick Mader's Stata code to R and provide useful variable labels and organization.

Move code to EC2

Make the existing code working on EC2 (upload open portal 311 tables and make paths absolute)

Repo Cleanup

Directory Structure

  • Clean, Well named set of directories. Examples include webapp, database, and models.
  • No random files in the root.
  • Explanation of each directory in README.
  • Sub-README's in appropriate folders
  • No directories named after DSSG specific info (ie, person names)
  • Should your team have more than one project, each should have it its own repo.
  • In your data or database folder, provide a way to re-create your database from scratch. .sql files are often appropriate for this.

README

  • Links to appropriate sections in wiki. See wiki issue for more info.
  • Answers: What have you built? In a few sentences.
  • Answers: How do you install it?
  • Answers: What needs to be done/How can I help?
  • Has some sort of Contact Info
  • Open source license
  • Future Issues opened.

Config

  • No public facing config info - Make sure never to hardcode in database url, password, etc.
  • Description of how you hide config info, ie yaml, environment variables, etc
  • config.example files
  • Requirements.txt or similar file.
  • Relative links in any html.

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.