Product designer with a statistics background
5.1 visualizations.png

2016 Election Machine Learning and Visualizations

 

Trends and Predictions in the 2016 Elections

I downloaded this dataset from Kaggle where it was uploaded by Ben Hamner. It contains 3 csv files, county_facts.csv, county_facts_dictionary.csv, and primary_results.csv. Using pandas, seaborn, sklearn, random forests, and Plot.ly, I discovered insights and predictions from the data—asking questions like:

What does the education level of the United States look like by County?
How does the counties in the United States look by race?
Which attributes do candidates like Donald Trump and Ted Cruz appeal to? Are they rich or poor, urban or rural, educated or uneducated?
As income, college education, whiteness, and density change, how does that affect the fraction of votes received by each candidate?

I constructed a model using Sklearn’s random forest to predict which candidate would emerge the winner for Democrats and Republicans.
Separated the data into train and test splits with grid search to find the optimal parameters on

•n_estimators
•max_features
•max_depth

Screen Shot 2018-12-28 at 6.19.23 PM.png
Screen Shot 2018-12-28 at 6.34.41 PM.png
Screen Shot 2018-12-28 at 6.47.16 PM.png
Screen Shot 2018-12-28 at 6.50.06 PM.png
Screen Shot 2018-12-28 at 6.50.22 PM.png
Screen Shot 2018-12-28 at 6.52.51 PM.png
Screen Shot 2018-12-28 at 6.53.19 PM.png
Screen Shot 2018-12-28 at 6.53.54 PM.png
Screen Shot 2018-12-28 at 6.55.18 PM.png
Screen Shot 2018-12-28 at 6.55.56 PM.png