August 2025

Problem Statement

  • Fuel efficiency (MPG) is a key factor for car buyers.
  • Weight and transmission are major predictors of MPG.
  • Goal: Simple tool to estimate MPG based on these factors.

Solution Overview

  • Interactive Shiny App.
  • Inputs:
    • Car Weight (Slider)
    • Transmission Type (Radio Button)
  • Output:
    • Predicted MPG in real-time.

Predictive Model Code

data(mtcars)
summary(lm(mpg ~ wt + am, data = mtcars))
Call:
lm(formula = mpg ~ wt + am, data = mtcars)

Residuals:
    Min      1Q  Median      3Q     Max 
-4.5295 -2.3619 -0.1317  1.4025  6.8782 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 37.32155    3.05464  12.218 5.84e-13 ***
wt          -5.35281    0.78824  -6.791 1.87e-07 ***
am          -0.02362    1.54565  -0.015    0.988    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 3.098 on 29 degrees of freedom
Multiple R-squared:  0.7528,    Adjusted R-squared:  0.7358 
F-statistic: 44.17 on 2 and 29 DF,  p-value: 1.579e-09

Example Prediction

model <- lm(mpg ~ wt + am, data = mtcars)
predict(model, newdata = data.frame(wt = 3, am = 1))
      1 
21.2395 

Try It Out