Project description
Electric vehicles (EVs) offer great potential to reduce local air pollution, cut greenhouse gas emissions, and reduce oil use by the transportation sector. Local governments and businesses need better tools to understand EV demand in their area to determine where to place charging stations — specifically, a geospatial view of demand versus current supply can help them strategize. This project identifies the geographic areas where the ratio of available public charging stations to registered EVs is lowest, and therefore most in need of additional charging infrastructure. Given the actual or estimated number of EVs and the actual number of public charging stations in a US zip code, we segment the zip codes in a state and calculate the ratio of public charging stations to vehicles to find where more public charging capacity is needed. We visualize the results as a choropleth state map of zip codes with five color gradations.
Proposed method
We first find clusters of labeled zip codes with similar predictors, then assign unlabeled zip codes to the cluster with the closest match of predictors. Finally, we create a regression model from the labeled data to estimate the number of EV registrations in the unlabeled zip codes within each cluster.
Data sources
Several data sources were combined using zip code as the primary key. Data availability had us using 2016 data to provide uniform measures for comparison. The American Community Survey (ACS) by the U.S. Census Bureau was the primary demographic and economic data source. The location of EV charging stations was extracted from the U.S. Department of Energy dataset, and EV registration data for some states came from Atlas EV Hub. Some states report EV registration by county rather than zip code, which we transformed using a zip code–county FIPS crosswalk that leverages HUD and Census Bureau data. After combining and wrangling the data, we had a file with over 39,000 rows (zip codes) and close to 550 features. All data was publicly available for download.
Clustering
The following steps were performed to cluster the data points with known EV registration numbers and then classify the data points with unknown registration numbers:
- Impute missing data for any feature with the median of each column.
- Divide the dataset into two: one with EV registration numbers and one without.
- Run the k-means clustering algorithm on the dataset with registration data. Graphing the SSE against the number of clusters showed that three clusters capture the most variation.
- Use the k-nearest neighbor (KNN) classification algorithm to train on the clustering model's output, using the cluster assignment as the response variable. Mean accuracy on training data and labels was 98.15%.
- Use the trained KNN model to predict the cluster for zip codes without EV registration numbers.
Some cities classified as cluster 0: Pensacola, FL; Beaumont, CA; Duluth, GA; Bessemer, AL; Norcross, GA; Calabasas, CA. Some classified as cluster 1: Willow Springs, MO; Colony, KS; Hurricane, UT; Oakville, IA; Braselton, GA. Some classified as cluster 2: Dallas, TX; Los Angeles, CA; Orlando, FL; Minneapolis, MN; Oakland, CA; Jacksonville, FL. Zip codes within each cluster share similarities in education level and population over 25 years old — most cities in cluster 0 are suburbs, and most in cluster 2 are urban.
Regression model
Since we know the actual EV registration for some zip codes, we used this dataset to train a regression model and impute EV registrations for zip codes without this information using predicted values. The steps for building the regression models are outlined below.
- Start with clustered data with registration information available.
- Start with over 500 predictors, including granular demographic data (education, age, income, transportation type, gender, household characteristics, and more) alongside the number of charging stations, gas prices, and electricity rates.
- For each cluster (0, 1, 2), perform feature selection to identify the top ten best-scoring predictors using univariate feature selection.
- For each cluster (0, 1, 2), train a regression model on 70% of the data and test on the remaining 30%.
The features selected for each cluster align with that cluster's characteristics. For cluster 0, with more suburbs, EV registration correlated with education, home value, mortgage (a proxy for income), and transportation. For cluster 1, with more rural areas, EV registration correlated with income level, unemployment, household characteristics, transportation, and rent. For cluster 2, more urban areas, the correlation was with home values, mortgage, and transportation type. Once a regression model was built for each cluster, the corresponding model was used to predict EV registration for zip codes where the data wasn't available; predictions were clipped at a minimum of zero and rounded to the nearest integer.
Visualization
The range of ratios for chargers per registered EV is shown on a map of the lower 48 states. Each zip code is displayed with a color from a gradient indicating the ratio of public charging stations to vehicles; a ratio of -1 indicates no public chargers in that zip code. The Python library Bokeh was used to generate a US map showing the location of electric vehicle charging stations, with box zoom, wheel zoom, scroll, and reset controls. Hovering over a zip code shows a tooltip with the zip code, number of EVs registered, number and type of public charging stations, and the ratio of public charging stations to registered EVs. Bokeh provided the display flexibility and features we needed with less programming complexity than D3.