In our project, our goal was to analyze the factors and trends that affected traffic stops in Burlington. More specifically, which factors affect stop outcome, and which factors are more prevalent in stop type. The source of the data is from the Burlington Government website and is an observational study. This data was collected from 2012 until October of 2023 and records: “Burlington Police Department Traffic Stops through 10/31/23”. The sample shows data from 2012 until 2023 and the sample was selected through the records kept from the Burlington Police Department.
Measurements were taken through recording daily statistics from traffic stops within Burlington. This data is interesting to us because it analyzes the trends that are shown in traffic stops that directly affect citizens and is one of the most common interactions between citizens and the police. Because it is the most common interaction, this is how the community comes to understand the police and how effective they feel their presence is around the community. The police and citizen interactions in a city like Burlington is an important variable in determining a number of factors like property value and how safe residents feel on a daily basis. It is also important to look at trends over time and analyze how improvements can be made in practice. Our data cleaning is shown below:
This is our the color scheme we used for the whole document:
From our data we decided to look at factors that affected stop outcome and stop type.
Our factors:
Gender: Male, Female, Other
Races: Black, Asian, Hispanic, White
Stop Type: Moving Violation (speeding, illegal turns), Investigatory (suspected drugs or weapons), Susp DUI (driving while under the influence), Equipment (lights, tags, license plates, etc…), Other, External
Stop_Outcome: Warning, Ticket, Arrest, No Action
## # A tibble: 29,583 × 11
## year month weekday hour minute race gender age stop_type stop_outcome
## <dbl> <dbl> <ord> <int> <int> <chr> <chr> <int> <chr> <chr>
## 1 2012 1 Wed 14 43 White Female 23 Moving Viol… Warning
## 2 2012 1 Sun 0 18 White Female 73 Equipment Warning
## 3 2012 1 Sun 0 18 White Male 25 Susp DUI Warning
## 4 2012 1 Sun 8 50 White Female 23 Equipment Warning
## 5 2012 1 Sun 8 56 White Female 17 Other Warning
## 6 2012 1 Sun 9 4 White Male 47 Equipment Warning
## 7 2012 1 Wed 14 50 White Female 29 Equipment Ticket
## 8 2012 1 Wed 15 13 White Male 28 Moving Viol… Warning
## 9 2012 1 Sun 9 19 White Female 34 Equipment Warning
## 10 2012 1 Sun 10 27 White Male 23 Moving Viol… Warning
## # ℹ 29,573 more rows
## # ℹ 1 more variable: time <dbl>
Traffic stops occur all the time, however, how often are people arrested or given a ticket or given a warning?
This graph below compares the number of arrests, tickets, and warnings.
| Total Amount of Each Outcomes | ||
| Arrest | Ticket | Warning |
|---|---|---|
| 106 | 7003 | 22424 |
We also graphed the table as a bar chart to visibly observe the difference between the three.
There were significantly more warnings than any other outcome, showing that Vermont police are easy on most people pulled over.
Because most stops are warnings we looked into what demographic was most likely pulled over.
Another factor we were interested in was time. The graph displays the number of stops by year and month. For almost all years, January had the most stops. There seems to be a steady decline over time on how many people are being pulled over. There are many factors that could be affecting this like the use of technology. While many believe technology to be bad, it is very helpful when driving between navigation, detecting if you’re driving over the line or if a car is near you, and for emergencies. Additionally, there are some important events that could have influenced a decline or increase in the number of stops per month. One most recent is COVID-19. COVID introduced online learning and working, causing more people to stay home, possibly explaining why after COVID there is a sharp decline in the number of stops from January to March of 2020, with trends continuing into 2023.
In this graph, we wanted to see the relationship between age and time of day on the type of traffic stop type that occurred. For this graph we only looked at five percent of the data so that we did not overcrowd the graph. In this data, it was very clear that most of the traffic stops were due to Moving Violations and Vehicle Equipment. We do not see very many investigatory reasons or suspect DUI reasons either. Another one of the main takeaways that we took from this graph was that there was the most activity for traffic stops from around 8pm to 4am at night, and we generally saw this in the younger demographic. This graph seems to represent the fact that younger people who are out later tend to get pulled over more for a variety of reasons, but mainly the fact that more of them are out on the streets increasing the odds. This data was not very surprising.
While Vermont is not very racially diverse, we were still interested if this was a factor that was significant on stop type.
To get the data for the graph below we filtered out the missing and other race categories, additionally, we pivoted the data so the type was in a column and the values for the sum were also in a column. This was done to get the total percentage of all races.
## # A tibble: 24 × 5
## race total type value percent
## <chr> <int> <chr> <int> <dbl>
## 1 Asian 1278 speeding 783 0.613
## 2 Asian 1278 vehicle_issues 440 0.344
## 3 Asian 1278 external 0 0
## 4 Asian 1278 other 24 0.0188
## 5 Asian 1278 DUI 8 0.00626
## 6 Asian 1278 investigatory 7 0.00548
## 7 Black 2488 speeding 1351 0.543
## 8 Black 2488 vehicle_issues 984 0.395
## 9 Black 2488 external 0 0
## 10 Black 2488 other 79 0.0318
## # ℹ 14 more rows
The data is grouped by race and shows the percentage of stop type by race. For all races, most stops are speeding with the second being something wrong with the vehicle. Our data shows that there is no significant difference between race and stop type. Vermont police are not typically discriminatory against race for all stop types. Though, this does not take into account people that were mis-identified.
In this graph, we are looking at the time of day and gender on the total number of traffic stops. We can take away that overall, more males are pulled over and that it also aligns generally with our data earlier that most of the traffic stops are from 8pm until 2am. From this graph, we took away that males are pulled over a lot more than females for all hours of the day. This shows that either, male drivers are less responsible than females, or that males in Burlington generally drive more than females and therefore are more likely to be stopped.
We graphed the percentage of arrests by age and observed the stop type for each age range. Our data shows that those arrested due to investigatory reasons were mostly aged 47 to 56. Additionally those pulled over for a suspected DUI were mostly ages 26 to 36. Though, this data is not very convincing when trying to predict whether someone will be arrested based on age or race. Because the arrests are few and far between, each individual case needs context for further analysis.
In our further exploration of our traffic stops data, we are going to use machine learning to see if we can predict the gender of the individual, based on the stop type, race, and age. Our other technique focused on stopping outcomes based on age and time.
Our first method is going to be making a classification tree. This method is going to look at gender based on stop type, race, and age.
## CP nsplit rel error xerror xstd
## 1 0.0018899 0 1.0000 1.000 0.02328
## 2 0.0015564 9 0.9829 1.005 0.02332
## 3 0.0007782 12 0.9782 1.003 0.02330
## 4 0.0005188 22 0.9704 1.011 0.02335
## 5 0.0003891 25 0.9689 1.012 0.02336
## 6 0.0002594 31 0.9665 1.016 0.02338
## 7 0.0001556 40 0.9642 1.024 0.02344
## 8 0.0000000 45 0.9634 1.025 0.02344
## 9 -1.0000000 104 0.9634 1.025 0.02344
From this, we see that the xerror is getting larger indicating that it is unlikely this method is going to produce results that are helpful. The cross validation error rate is increasing meaning that the model is getting worse and worse at predicting the outcome.
## xerror cutoff cp prune value
## 1.02328 0.00189
These values will not be of significance to us after understanding that our xerror rate is increasing the more cuts we make in the nodes.
## Overall
## age_range 54.35
## race 62.30
## stop_type 62.60
## Overall
## stop_type 0
## race 0
## age_range 0
Here we see that there are no meaningful differences in the variable importance of the explanatory variables.
## gender Fem Mal Oth
## Male [.30 .70 .00] null model
Summary for Classification Tree In our attempt to use Machine learning to make predictions about a certain gender based on stop type, age and race, we were unable to find meaningful results that utilized the classification tree. Through our exploration of Machine Learning tools on our data set, we found that there are serious limitations in meaningfully interacting with our data when utilizing machine learning tools. As we found out through the variable importance function as well as our gradually rising xerror rate, you can see that they are all pretty equal, meaning that they are not actually important at determining the output at all. Trying to make predictions about someone’s gender based on factors such as age, race, and stop_type does not reveal anything that is meaningful. It would be better just to guess.
Using KNN Classification we are hoping to predict stop outcomes by time and age.
## # A tibble: 28,992 × 11
## year month weekday hour minute race gender age stop_type time outcome
## <dbl> <dbl> <ord> <int> <int> <chr> <chr> <int> <chr> <dbl> <fct>
## 1 2012 1 Wed 14 43 White Female 23 Moving Vio… 883 0
## 2 2012 1 Sun 0 18 White Female 73 Equipment 18 0
## 3 2012 1 Sun 0 18 White Male 25 Susp DUI 18 0
## 4 2012 1 Sun 8 50 White Female 23 Equipment 530 0
## 5 2012 1 Sun 8 56 White Female 17 Other 536 0
## 6 2012 1 Sun 9 4 White Male 47 Equipment 544 0
## 7 2012 1 Wed 14 50 White Female 29 Equipment 890 1
## 8 2012 1 Wed 15 13 White Male 28 Moving Vio… 913 0
## 9 2012 1 Sun 9 19 White Female 34 Equipment 559 0
## 10 2012 1 Sun 10 27 White Male 23 Moving Vio… 627 0
## # ℹ 28,982 more rows
## # A tibble: 28,992 × 11
## year month weekday hour minute race gender age stop_type time outcome
## <dbl> <dbl> <ord> <int> <int> <chr> <chr> <dbl> <chr> <dbl> <fct>
## 1 2012 1 Wed 14 43 White Female 0.204 Moving Vi… 0.614 0
## 2 2012 1 Sun 0 18 White Female 0.337 Equipment 0.0125 0
## 3 2012 1 Sun 0 18 White Male 0.210 Susp DUI 0.0125 0
## 4 2012 1 Sun 8 50 White Female 0.204 Equipment 0.368 0
## 5 2012 1 Sun 8 56 White Female 0.188 Other 0.372 0
## 6 2012 1 Sun 9 4 White Male 0.268 Equipment 0.378 0
## 7 2012 1 Wed 14 50 White Female 0.220 Equipment 0.618 1
## 8 2012 1 Wed 15 13 White Male 0.218 Moving Vi… 0.634 0
## 9 2012 1 Sun 9 19 White Female 0.233 Equipment 0.388 0
## 10 2012 1 Sun 10 27 White Male 0.204 Moving Vi… 0.436 0
## # ℹ 28,982 more rows
We need to normalize all of our data so it’s within the same range. We created a normalize function to help with this called normalize. We saved the normalized data in traffc_norm.
## # A tibble: 28,992 × 11
## year month weekday hour minute race gender age stop_type time
## <dbl> <dbl> <ord> <int> <int> <chr> <chr> <dbl> <chr> <dbl>
## 1 2012 1 Wed 14 43 White Female -0.878 Moving Violation 0.0826
## 2 2012 1 Sun 0 18 White Female 2.43 Equipment -1.98
## 3 2012 1 Sun 0 18 White Male -0.746 Susp DUI -1.98
## 4 2012 1 Sun 8 50 White Female -0.878 Equipment -0.759
## 5 2012 1 Sun 8 56 White Female -1.28 Other -0.745
## 6 2012 1 Sun 9 4 White Male 0.711 Equipment -0.726
## 7 2012 1 Wed 14 50 White Female -0.481 Equipment 0.0993
## 8 2012 1 Wed 15 13 White Male -0.547 Moving Violation 0.154
## 9 2012 1 Sun 9 19 White Female -0.150 Equipment -0.690
## 10 2012 1 Sun 10 27 White Male -0.878 Moving Violation -0.528
## # ℹ 28,982 more rows
## # ℹ 1 more variable: outcome <fct>
We also standardized the data so the mean and standard deviation are all between 0 and 1. We created a function called standardize and saved this data to traffic_stan.
## # A tibble: 100 × 3
## k norm_acc stan_acc
## <int> <dbl> <dbl>
## 1 1 -1 -1
## 2 2 -1 -1
## 3 3 -1 -1
## 4 4 -1 -1
## 5 5 -1 -1
## 6 6 -1 -1
## 7 7 -1 -1
## 8 8 -1 -1
## 9 9 -1 -1
## 10 10 -1 -1
## # ℹ 90 more rows
We want to compare values of k from 0 to 100. We created a new data frame to input each normalized data point and standardized data point with the value of k.
## # A tibble: 100 × 3
## k norm_acc stan_acc
## <int> <dbl> <dbl>
## 1 1 0.647 0.646
## 2 2 0.662 0.659
## 3 3 0.693 0.691
## 4 4 0.699 0.699
## 5 5 0.715 0.713
## 6 6 0.722 0.718
## 7 7 0.730 0.727
## 8 8 0.733 0.730
## 9 9 0.740 0.734
## 10 10 0.739 0.736
## # ℹ 90 more rows
Our for loop goes through each point and gets the normalized and standardized data for each value of k by running knn on each value.
We graphed our data from the for loop above, it seems to show that normalized and standardized data has relatively similar accuracy for each value of k.
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 21127 6576
## 1 860 429
##
## Accuracy : 0.744
## 95% CI : (0.738, 0.749)
## No Information Rate : 0.758
## P-Value [Acc > NIR] : 1
##
## Kappa : 0.031
##
## Mcnemar's Test P-Value : <2e-16
##
## Sensitivity : 0.9609
## Specificity : 0.0612
## Pos Pred Value : 0.7626
## Neg Pred Value : 0.3328
## Prevalence : 0.7584
## Detection Rate : 0.7287
## Detection Prevalence : 0.9555
## Balanced Accuracy : 0.5111
##
## 'Positive' Class : 0
##
## Length Class Mode
## positive 1 -none- character
## table 4 table numeric
## overall 7 -none- numeric
## byClass 11 -none- numeric
## mode 1 -none- character
## dots 0 -none- list
We looked at how age and time of the day (in minutes) affected the stop outcome. From our data we found that there was no significance between age and time on stop outcome. We first normalized and standardized the data and then ran KNN. Our confusion matrix shows the normalized data with a no information rate of 0.758 and accuracy 0.744. Since the no information rate is larger than the accuracy this further highlights the fact that our data isn’t suited for this machine learning method.
From our data we found that there are a few factors that affect whether someone will be stopped or not by a police officer. The most common time was from 10pm to 2am. This is probably due to people going home and wanting to get home quickly, or drinking and driving. We observed little to no signs of discrimination in race as every race had roughly the same percentage for each stop type, with speeding being the most common, again leading into some of our limitations within the data. The majority of Vermont’s population is white, with 92.93% of Vermont citizens being white. Additionally, we found that gender was another factor with males being pulled over significantly more throughout the whole day. Further, we also looked at age and time. Our data shows that when it comes to different stop types, most people stopped are for moving violations and vehicle equipment. The younger drivers were more likely to be stopped, most likely due to more reckless driving or driving late at night or drinking and driving. Overall, the typical demographic for being pulled over were white males, driving late at night, ages 20 to 30. We were curious as to how arrests factored into this demographic and grouped ages in age ranges of 10 years. Those that were pulled over for investigatory reasons were typically ages 46 to 57 and were arrested 6% of the time, likely due to having a suspicion of criminal or illegal activities. Those who were pulled over for speeding were likely to not get arrested, this is because speeding/moving violation is the most common stop type. Overall, our data is suited for retrospective analysis and making further judgement about the city and state that the data was taken in.
There were many limitations with our data as most of it was categorical and using our factors to make predictions showed us that it would be better to guess. Because of Vermont’s population our data leans towards a less diverse population and doesn’t show any significance in race. This is why our regression tree only showed one box, because the other nodes were insignificant. Our data is better suited for retrospective analyzation, as our graphs showed trends about traffic stops. For future investigations, we would recommend other machine learning types to show predictions. Additionally, one could look at counties in Vermont if given them and map it based on different factors. The data is interesting, but very limiting and not very diverse. In the future, we would look at different states that had a larger population, and more diversity.
In terms of bias, obviously no data is unbiased, but we found little that was significant, or conveys the message that there may have been some sort of bias. With that being said, we think that due to the unpredictability in traffic stops, there is an inherent bias in the judgment of police officers in individual cases in regards to racial classification. Due to the nature of record keeping, race identification and officer differences, it is very likely that there are lots of discrepancies in how race was recorded in our data, and whether the subject of the traffic stop agrees with, or is even considered, that race. This is a problem that is shown all around the country and we think that it is a factor that plays a role in the data we analyzed involving race.