GithubHelp home page GithubHelp logo

densitymapping's Introduction

densityMapping

Python tool for creating density maps of events (drunk tweets, police shootings, etc). Below is a sample map created with this tool using Twitter data: color denotes the fraction of #beer or #wine tweets which are about #wine, with redder areas indicating more wine.

Alt text

This code can be used in two ways. Run plotDensity.py to see examples of both. sample_data.csv contains a sample data file.

Way 1: You have a file of latitude, longitude pairs and you want to see where they cluster most densely. Eg, I want to plot the density of police shootings. Uses kernel density estimation.

Way 2: You have a file with two types of latitude, longitude pairs: points of interest, and background points. Eg, I want to plot the fraction of all tweets about alcohol which are about beer: beer tweets are the points of interest, and alcohol tweets are the background. Or I want to plot the fraction of all tweets about football which support the Patriots: Patriots tweets are the points of interest, and football tweets are the background. I think way 2 is usually the correct thing to do (otherwise, your map is heavily correlated with population density), but it does require you to have two types of events. Uses k-nearest neighbors estimation.

This code requires pylab, sklearn, numpy, and pandas to run.

Please contact Emma Pierson (emmap1 "at" cs "dot" stanford "dot" edu) with questions, comments, requests, or bugs, or see blog post or Quartz articles for full details.

densitymapping's People

Contributors

epierson9 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.