MPGView: Find the Vehicle Best for Fuel Economy
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
America is a nation on wheels. According to 2014 stats, there are 797 cars owned per 1000 people in America.ref Besides paying the price for the vehicle, people spend thousands of dollars on gas every year. In fact, the annual fuel cost varies dramatically between cars and a small change in a vehicle’s parameters can add 1000 dollars to a gas bill every year. Therefore, understanding fuel consumption is important, especially for those who want a fuel efficient car in the near future. For me, a training data scientist and car enthusiast, I targeted my project towards MPG and created this shiny app—MPGView. What is described here is a Shiny app built in R that provides multiple perspectives on gas usage in cars.
About the Data
2012 to 2017 vehicle data was downloaded from the U.S. Department of Energy. Fuel economy data comes from vehicle testing done at the Environmental Protection Agency’s National Vehicle and Fuel Emissions Laboratory in Ann Arbor, Michigan, and by vehicle manufacturers with oversight by EPA.
Data merging, cleaning and feature creation were performed in R, and the app is powered by the Shiny package. All code can be found here.
Using the App
When entering the app, you will see a welcome page. This page gives a brief introduction to this app. On the top of the screen you will see three additional tabs. “Understand MPG” tab will help users visualize how mpg changes between different types of cars. The “Explore by Manufacturer” tab is a place for users to see the progress of increasing fuel economy by each manufacturer. Finally, “Select Your Next Vehicle” tab is a place to get a recommendations on your next car based on the parameters selected. Now let’s dive into the app and examine the functions one by one.
As shown above, users can select the type of vehicle and an MPG measurement on the left. After clicking “submit”, four plots will be generated to demonstrate the behavior of mpg with respect to other parameters. On the top left is a box-plot showing the distribution of MPG values versus transmission type. Below is a scatter plot and curve fit of MPG versus engine displacement. The two graphs on the right are vehicle distribution among fuel requirements and drive types, respectively.
Above shows the interface of the second panel. Users can explore the development of fuel efficiency across six years (2012 – 2017). By selecting a vehicle manufacturer of interest, an interactive google motion chart will be generated to facilitate the visualization.
In the final panel, users can filter the entire data set based on the information set on the left. Selections include:
- Vehicle Condition: New, Like New, Used
- Vehicle Type: Car, SUV, Truck, Van
- Vehicle Class: Family, Luxury, Super
- Transmission Type: Automatic, Manual
After clicking “Get range” button, a slider input will be generated based on the information selected. Users can then determine how much he/she wants to pay for fuel each year. After all selections are made, click “Get result” button and this will generate an interactive table containing all vehicles that fit the requirements along with a variety of key parameters of these vehicles.
Takeaways and Future Direction
By exploring this app, we can see that fuel economy is highly related to both vehicle type and their parameters. For example, most of the SUVs require regular gasoline while most cars require premium gasoline, and cars with continuous variable transmission are relatively more fuel efficient.
This app can be useful when looking for a car. For example, while everyone know that SUV’s use more gas than a Tesla, let’s say, there are still choices to be made among SUV’s. A Lexus RX Hybrid is a better choice than a Range Rover in terms of expected expenditure on gas.
To expand the function of this app, more features can be added to the data. In exploring the MPG tab, adding features like vehicle weight will result in a more complete exploration. In the recommendation tab, including vehicle price in selection bar can help users locate their desired car more effectively. Last but not least, besides mechanistic parameters, we can further expand our recommendation system by inclusion of vehicle style features.
The post MPGView: Find the Vehicle Best for Fuel Economy appeared first on NYC Data Science Academy Blog.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.