Introduction

Predicting car prices is a common application of machine learning in the automotive industry. This Shiny app demonstrates an interactive way to predict car prices based on various features using a trained machine learning model.


Dataset

We simulate a dataset for demonstration purposes. Below is the sample dataset used in the plots.

# Simulating car_data dataset
set.seed(123)
car_data <- data.frame(
  engine_size = runif(100, 1.0, 4.0),  # Engine size in liters
  price = runif(100, 10000, 40000),    # Car price in USD
  fuel_type = sample(c("Petrol", "Diesel", "Electric"), 100, replace = TRUE),
  age = sample(1:15, 100, replace = TRUE) # Car age in years
)


library(ggplot2)
ggplot(car_data, aes(x = engine_size, y = price)) +
  geom_point(color = "blue") +
  labs(title = "Engine Size vs Price", x = "Engine Size (L)", y = "Price (USD)") +
  theme_minimal()

ggplot(car_data, aes(x = fuel_type, y = price, fill = fuel_type)) +
  geom_bar(stat = "summary", fun = "mean") +
  labs(title = "Average Price by Fuel Type", x = "Fuel Type", y = "Average Price (USD)") +
  theme_minimal()