A Shiny application developed to estimate a vehicle’s MPG (miles per
gallon) based on its weight and number of cylinders.
Dataset used: mtcars.
Slide 2 — The Problem
Why this application?
Drivers want to anticipate a vehicle’s fuel consumption.
Weight and number of cylinders
directly influence this consumption.
Goal: provide a simple, fast, and reliable estimation.
Slide 3 — The Solution
An interactive Shiny
application
Inputs:
Vehicle weight (via a slider)
Number of cylinders (via a select box)
Outputs:
MPG prediction using a linear model
Plot showing the prediction as a red point
Slide 4 — R Code Example
Here is an example prediction based on the model used:
# Load datadata(mtcars)# Create the linear modelmodel <-lm(mpg ~ wt + cyl, data = mtcars)# Prediction for a 3-ton, 6-cylinder vehiclepredict(model, data.frame(wt =3, cyl =6))