Car MPG Explorer & Predictor

Shruthi R
October 28, 2026

A simple interactive Shiny application for exploring and predicting automobile fuel economy.

Live application: https://shruthi1232131231.shinyapps.io/mpg_predictor/

Source code: https://github.com/ShruthiRmit/Car-MPG-Explorer-Predictor

Why This App?

The problem

Fuel economy depends on several vehicle characteristics, so a single-variable comparison can be misleading.

The idea

The Car MPG Explorer & Predictor lets a user choose:

  • transmission type,
  • cylinders,
  • vehicle weight, and
  • horsepower.

The app then estimates MPG instantly and explains the result in plain language.

Why it is useful

It turns a regression model into something a novice can explore without writing any R code.

How the Prediction Works

The Shiny server fits a multiple linear regression model to R's built-in mtcars data.

cars <- mtcars
cars$am <- factor(cars$am, levels = c(0, 1),
                  labels = c("Automatic", "Manual"))
cars$cyl <- factor(cars$cyl)

fit <- lm(mpg ~ wt + hp + am + cyl, data = cars)

round(summary(fit)$r.squared, 3)
[1] 0.866

The R code above is evaluated when this presentation is rendered.

A higher R-squared indicates that the selected vehicle characteristics explain a substantial share of MPG variation in this small dataset.

What the User Gets

Interactive inputs

The user changes sliders and selectors for weight, horsepower, cylinders, and transmission.

Reactive server calculations

Every change triggers a new server-side prediction.

The application displays:

  1. Predicted MPG
  2. 95% prediction interval
  3. Difference from the mtcars average
  4. A plot comparing the prediction with the original cars

The app also includes a dedicated How to Use tab so the documentation is available directly on the Shiny site.

Why It Is More Than a Basic Demo

Key strengths

  • Multiple user-controlled inputs rather than one slider
  • A fitted prediction model rather than a simple arithmetic transformation
  • Reactive uncertainty estimates
  • A visual comparison with the original dataset
  • Built-in documentation for novice users
  • Clear statement of limitations

Try it

Shiny app: https://shruthi1232131231.shinyapps.io/mpg_predictor/

GitHub code: https://github.com/ShruthiRmit/Car-MPG-Explorer-Predictor

The project demonstrates how statistical modeling, reactivity, and user-centered design can be combined in a compact data product.