MPG Predictor

Maitreya Tarmale
October 27, 2026

A Shiny app that predicts a car's fuel efficiency (miles per gallon)

The Problem

  • How fuel efficient is a car, given its features?
  • Buyers and students often want a quick estimate without doing any statistics.
  • This app uses the built-in mtcars dataset to predict MPG instantly.

How to Use the App

  1. Open the app link (on the last slide).
  2. Use the sliders/dropdowns to choose car weight, horsepower, and transmission.
  3. The predicted MPG updates automatically.
  4. Instructions are also on the app's Documentation tab.

Under the Hood

The app fits a linear regression on mtcars using weight, horsepower and transmission type.

fit <- lm(mpg ~ wt + hp + am, data = mtcars)
round(summary(fit)$r.squared, 3)
[1] 0.84
predict(fit, data.frame(wt = 3, hp = 120, am = 1))
       1 
22.95341 

Try It Yourself