top of page
Image by Cedric Letsch


Problem & Motivation

Gun violence is a continued and pressing problem in the United States. Statistics from Everytown (a popular gun violence website) and the CDC tell a grim story. In 2021 which is the last year for which we have complete data, 48,830 people were killed by guns in the US. Fifty-four percent were suicides and 43% were homicides, with 3% being in another category, such as accidents. Between 2012 and 2021, gun-related homicides have increased by 73%, and gun-related suicides have increased by 19%. The US has only 4% of the world’s population but 44% of the world’s gun suicides. Comparing our country to England and Wales, the US had 100 times the number of gun-related homicides per capita in 2021. The leading cause of mortality of children in the US is death by a gun. 


So what can we do about it? Some point to mental health issues as being the leading cause of gun violence. It’s obvious that the US does not have 100 times the number of mental health issues than England and Wales. The solution appears likely to be gun control measures, but the question is which ones to implement. We know what laws have been passed in each state and when they were passed. We know state statistics on gun deaths and injuries which we can analyze. Our project is focused on this issue — which laws make the biggest difference? There are some complexities in doing this analysis. Gun ownership rates are higher in some states than others. For example, we have weak gun laws in New Hampshire, but surrounding states have strong ones, which significantly affect gun deaths in New Hampshire. Enforcement varies by state, and new laws take time to make an impact. 

The bottom line is that understanding which laws to enact could reduce gun violence in the US. There is some excellent information available today but even with all the available information that’s out there, it’s difficult to prioritize which measures to implement. With limited scientific evidence on the effects of different gun laws, policymakers and the public frequently rely on the views of experts but these experts often have opposing views on the probable effects of different laws and their merits. 


Our proposed solution is the Gun Policy Effectiveness Predictor. The solution uses statistics and machine learning. We train the model on gun laws and their outcomes to predict how different policies are likely to affect gun violence rates. The core of this functionality is provided through an interactive modeling tool that allows the user to select specific states of interest and to either present statistics on gun deaths in that state or to provide a prioritized list of gun law changes that can reduce the number of deaths in that state. 

Data Source & Data Science Approach

Our datasets are from several offline sources, meaning there is no like dataset that needed to be updated frequently. Datasets from CDC provided firearm deaths by month and cause of death. Rand Corporation datasets were used to identify gun control laws passed in every state and the date those laws were put in place. The CDC and Rand datasets were used to develop the statistical and machine learning model. Additional data was pulled from the Gun Violence Archive and Kaiser Family Foundation to support data visualization. Google Colab was used for the Exploratory Data Analysis (EDA) and for initial model development.  Data files were placed in GitHub and Amazon Sagemaker pulled that data for active processing. The coefficients for each gun law for each state is derived from statistical modeling. We further utilize Tableau to create final interactive visualizations. The WiX tool was used to create the website. 

With regard to the data and modeling pipeline, there were several steps

  1. Importing the data from CDC and Rand datasets into a data frame

  2. Preprocessing, converting data formats, addressing missing values, and joining datasets

  3. Text processing, using the Natual Language Toolkit (NLTK) and Bidirectional Encoder Representations from Transformers (BERT) to convert text content of gun laws into numerical representations

  4. NLP Modeling, using BERT and PyTorch

  5. Topic modeling using the NMF algorithm to distill laws into topics

  6. Gun law effect attribution using a linear effects model that accounts for variations between states and time periods and to help provide an estimate of the effect of implementing a particular topic in a state

  7. State law recommendations by first identifying which laws were already implemented in a state and determining which unimplemented topic was most likely to reduce gun deaths in that state. Using Bidirectional Auto-Regressive Transformers (BART) and OpenAI's GPT 3.5, topics were translated into human-understandable sentences

The overall architecture and pipeline are shown in the following illustration. 

Screenshot 2023-08-06 at 7.13.28 PM.png

Key Learnings and Impact

Our unique value proposition is that we provide an interactive modeling tool that uses statistics, natural language processing, and visualization to provide insights and actionable recommendations on leading candidates for gun control laws in each state to reduce gun violence.

Our conclusion is that certain gun laws do appear to have an impact on reducing gun violence while there are others either because of their content or because of the way they are written, either have no effect or in some cases may actually increase gun violence. For example, in states with more highly restrictive laws and lower gun death rates, the following provisions have a correlation with a reduction in gun deaths:

  • Background checks

  • Prohibited possessor laws (e.g. mental health, extreme risk protection)

  • Dealer license requirements

  • Restrictions on the minimum age

  • Required reporting of lost or stolen firearms

  • Child access laws related to negligent storage

Looking at the top three recommendations across all states, the following were noted as the most common recommendations for states to improve their existing gun laws, in order of frequency: 

  • Any person who sells, barters, gives, or furnishes a handgun to a minor, having good cause to believe them to be a minor, is guilty of a Class 6 felony and must undergo a criminal history background check

  • No person may carry a pistol or revolver, possess a dangerous weapon, firearm, or short-barreled shotgun, in any vehicle or on or about their person on school premises without a license or permit

  • No person or organization may sell, purchase, or repair firearms, destructive devices, parts, or ammunition without a dealer's license; registrants must comply with all duties imposed by this act

  • A licensing authority may grant a permit to purchase, rent, or lease firearms to adults, and the state has the authority to regulate firearms and knives, while municipalities may not

  • Minors under eighteen cannot possess or carry deadly weapons, except on their own or family premises or with parental/guardian permission

  • A protective order is a restraining order issued ex parte, after notice and hearing, or in a judgment, and prohibits a person subject to the order from owning, possessing, purchasing, or receiving firearms or ammunition while in effect

  • A firearms dealer must obtain a completed statement of intent, inspect proof of identity, and request a records check before transferring any handgun

This tool can be a valuable tool for researchers and gun control advocates to analyze laws in specific states, how states compare to each other, and potential changes that can reduce gun violence. It is recommended that a more detailed evaluation be performed of the specific gun control text and associated implementation measures that have the most significant impact.  


We are grateful to have the guidance and encouragement from our Capstone Advisors, Joyce Shen, and Dr. Zona Kostic, of the Master in Data Science program at the School of Information, University of California, Berkeley. We could not have undertaken this journey without the advice and support of Dr. Nikole Hockley, co-CEO of Sandy Hook Promise. We also wish to thank Patrick McDermott from Google for his assistance with our statistical and modeling techniques.

bottom of page