Your Name
2026-09-06
The Car MPG Predictor is a Shiny application that allows users to predict the fuel efficiency (Miles Per Gallon) of a car based on specific characteristics.
This application is built for the Coursera “Developing Data Products” course project. It features:
mtcars datasetThe application uses the mtcars dataset, which was extracted from the 1974 Motor Trend US magazine, and comprises fuel consumption and 10 aspects of automobile design and performance for 32 automobiles.
# Display the first few rows of the dataset features used in the app
head(mtcars[, c("mpg", "hp", "wt", "am")])
mpg hp wt am
Mazda RX4 21.0 110 2.620 1
Mazda RX4 Wag 21.0 110 2.875 1
Datsun 710 22.8 93 2.320 1
Hornet 4 Drive 21.4 110 3.215 0
Hornet Sportabout 18.7 175 3.440 0
Valiant 18.1 105 3.460 0
A linear regression model is fitted to predict mpg using Horsepower (hp), Weight (wt), and Transmission Type (am).
# Fit the model
model <- lm(mpg ~ hp + wt + am, data = mtcars)
# Display the coefficients
summary(model)$coefficients
Estimate Std. Error t value Pr(>|t|)
(Intercept) 34.00287512 2.642659337 12.866916 2.824030e-13
hp -0.03747873 0.009605422 -3.901830 5.464023e-04
wt -2.87857541 0.904970538 -3.180850 3.574031e-03
am 2.08371013 1.376420152 1.513862 1.412682e-01
Check out the source code on GitHub and try the app on shinyapps.io!