Car MPG Predictor

Your Name
2026-05-19

Overview

This project presents a Shiny application called Car MPG Predictor.

The app predicts car fuel efficiency using the mtcars dataset.

Main features:

  • user input widgets
  • reactive prediction
  • data visualization
  • server calculations

Inputs

Users can change:

  • car weight
  • horsepower
  • number of cylinders
  • transmission type

The prediction updates automatically.

Model

model <- lm(mpg ~ wt + hp + cyl + am, data = mtcars)

summary(model)

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

Residuals:
    Min      1Q  Median      3Q     Max 
-3.4765 -1.8471 -0.5544  1.2758  5.6608 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 36.14654    3.10478  11.642 4.94e-12 ***
wt          -2.60648    0.91984  -2.834   0.0086 ** 
hp          -0.02495    0.01365  -1.828   0.0786 .  
cyl         -0.74516    0.58279  -1.279   0.2119    
am           1.47805    1.44115   1.026   0.3142    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 2.509 on 27 degrees of freedom
Multiple R-squared:  0.849, Adjusted R-squared:  0.8267 
F-statistic: 37.96 on 4 and 27 DF,  p-value: 1.025e-10

Prediction Example

model <- lm(mpg ~ wt + hp + cyl + am, data = mtcars)

newdata <- data.frame(
  wt = 3,
  hp = 120,
  cyl = 4,
  am = 1
)

predict(model, newdata)
       1 
23.83039 

Conclusion

The application demonstrates:

  • reactive programming
  • user interaction
  • predictive modeling
  • interactive visualization

This project was developed using Shiny and RStudio.