MPG Prediction Using a Shiny Application

Monalisa H V

1/8/2026

Introduction

Fuel efficiency is an important factor in the automotive industry.
Miles Per Gallon (MPG) measures how efficiently a vehicle uses fuel.

This project demonstrates how an interactive Shiny application can be used to: - Predict MPG - Visualize relationships between vehicle attributes - Support data-driven decision making

Problem Statement

Choosing a fuel-efficient vehicle is challenging because: - MPG depends on multiple factors - Manual calculations are difficult - Static models lack interactivity

Objective:
To build an interactive application that predicts MPG based on: - Car weight
- Horsepower

Application Overview

The Shiny application allows users to: - Select car weight using a slider - Select horsepower using a slider - Predict MPG dynamically - View a regression plot of MPG vs weight

The app uses a linear regression model trained on automobile data.

MPG Prediction Example

Example input values: - Car weight = 3 (1000 lbs) - Horsepower = 110

The model calculates and displays the predicted MPG based on these inputs.

Users can modify the inputs to observe how MPG varies.

MPG vs Weight Plot

Model Summary

summary(lm(mpg ~ wt + hp, data = mtcars))
## 
## Call:
## lm(formula = mpg ~ wt + hp, data = mtcars)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -3.941 -1.600 -0.182  1.050  5.854 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 37.22727    1.59879  23.285  < 2e-16 ***
## wt          -3.87783    0.63273  -6.129 1.12e-06 ***
## hp          -0.03177    0.00903  -3.519  0.00145 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.593 on 29 degrees of freedom
## Multiple R-squared:  0.8268, Adjusted R-squared:  0.8148 
## F-statistic: 69.21 on 2 and 29 DF,  p-value: 9.109e-12

Conclusion

This project demonstrates: - Use of Shiny for interactive analytics - MPG prediction using linear regression - Real-time visualization and user input handling

The application helps users understand how vehicle characteristics affect fuel efficiency.

Thank You

Thank you for reviewing this project.