Which New Yorkers are not licensing their dogs?

Tyler Wilbers
Posted on Oct 22, 2018

The Data

All dog owners in New York City are required by law to license their dogs. Through NYC Open Data, the Department of Mental Health and Hygiene provides a data set of active Dog Licenses from 2016 to 2017. This data set provides 14 features on 122K observations of registered dogs. Some features include:

  • User-provided dog name (unless specified otherwise)
  • Animal gender
  • Month and year dog was born
  • Dog breed
  • Owner Borough
  • Owner zip code


I represented this data set with a interactive geographic visualization that shows the density of dogs per zip code. This was achieved by using a leaflet widget to represent zip codes as polygons on a map of New York running on a Shiny app. The polygons accompanied with census data was retrieved from NYC Open Data in the form of a shape file. The color of the polygons represent the relative population density of the dogs in that zip code, light yellow being the least densely populated zip codes and dark red being the most densely populated. The widget allows for the user to interact with the map by clicking on the zip codes to receive information about that area population of dogs. For each zip code, it shows the total number of dogs, the population, the most common breed, and the most common dog name.

From the heat map style representation the user can quickly tell approximately how densely populated each of New York’s zip code is with dogs. The map also shows the population density of dogs per capita. This changes the distribution of colors to be more uniform as most zip codes have about average dogs per capita, while some zip codes with a smaller population size over have a relatively high number of dogs. Notice Battery Park and the Financial District in darker colors below:

The same information of the previous two maps can also be presented in a histogram where each bar is the frequency of dogs for each zip code colored by borough and the dark points represent the number of dogs per capita (100K people).

The web app also allows the user to select a breed to represent a population density map relative to a particular breed. A word cloud will also be generated with the most frequent names for that breed. Yet another area of the web app involves statistical information on the diversity of breeds by borough. See the top ten dog breed for Brooklyn below.


With the data provided, I was able to run a simulation to find the zip codes with the most under registered dogs for their population size. I ran a sample simulation the same size as the number of registered dogs in the data set relative to a probability distribution derived from each zip code’s population size. Iterating this sample simulation ten thousand times produced an expected value for the population of dogs in each zip code and the Shiny app was able to represent this information graphically. The zip codes with a larger number of registered dogs than the expected value are represented in light yellow, while the zip codes with far fewer registered dogs than the expected value are in dark red. You can tell that Brooklyn, Queens and the Bronx likely have higher density of unregistered dogs than Manhattan and Staten Island. I am confident this statistical method could be used by NYC Department of Mental Health and Hygiene to find which zip codes are the least likely to register their dogs.

About Author

Leave a Comment

No comments found.

View Posts by Categories

Our Recent Popular Posts

View Posts by Tags

#python #trainwithnycdsa 2019 airbnb Alex Baransky alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus API Application artist aws beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep Bundles California Cancer Research capstone Career Career Day citibike clustering Coding Course Demo Course Report D3.js data Data Analyst data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization Deep Learning Demo Day Discount dplyr employer networking feature engineering Finance Financial Data Science Flask gbm Get Hired ggplot2 googleVis Hadoop higgs boson Hiring hiring partner events Hiring Partners Industry Experts Instructor Blog Instructor Interview Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter lasso regression Lead Data Scienctist Lead Data Scientist leaflet linear regression Logistic Regression machine learning Maps matplotlib Medical Research Meet the team meetup Networking neural network Neural networks New Courses nlp NYC NYC Data Science nyc data science academy NYC Open Data NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time Portfolio Development prediction Prework Programming PwC python python machine learning python scrapy python web scraping python webscraping Python Workshop R R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn Selenium sentiment analysis Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau team TensorFlow Testimonial tf-idf Top Data Science Bootcamp twitter visualization web scraping Weekend Course What to expect word cloud word2vec XGBoost yelp