Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

🛒 Retail Units Sold Prediction App

A machine learning web application that predicts the number of retail units sold based on various business and contextual factors such as inventory levels, discounts, promotions, and seasonal trends.

🚀 Live App: Click to Open on Hugging Face Spaces


📌 Project Overview

This project presents an end-to-end regression pipeline designed to forecast retail sales performance.
The goal is to predict Units Sold using historical sales, demand forecasts, and other external features.

Two algorithms were tested — KNN Regressor and Linear Regression — and the final deployed model uses Linear Regression due to superior accuracy and generalization.


📂 App Structure

The application is built using Streamlit and organized into multiple interactive pages:

  1. Introduction
  2. Problem Statement & Objective
  3. Data Understanding
  4. Exploratory Data Analysis (EDA)
  5. Feature Engineering
  6. Model Overview
  7. Model Prediction

📊 Dataset

  • The dataset was sourced from an open data repository.
  • Contains both numerical and categorical features such as:
    • Category, Region, Inventory Level, Demand Forecast, Discount, Weather Condition, Holiday/Promotion, and Seasonality
  • Target variable: Units Sold

🔍 Exploratory Data Analysis (EDA)

  • Handled missing values and outliers
  • Visualized feature distributions, boxplots, and correlations
  • Identified major factors influencing sales performance:
    • High demand during festive/holiday seasons
    • Direct relationship between inventory level and units sold
    • Discounts and promotions significantly increased sales

🛠️ Feature Engineering

  • Categorical Encoding: Ordinal Encoding applied to categorical variables
  • Scaling Techniques: Used both StandardScaler and MinMaxScaler depending on the algorithm
  • Feature Selection:
    • Mutual Information after Standard Scaling
    • SelectKBest (Chi²) after MinMax Scaling
  • Outlier Handling: Applied capping on Units Sold and Demand Forecast

🤖 Models Used

1️⃣ K-Nearest Neighbors (KNN) Regressor

  • Non-parametric, distance-based algorithm
  • Suitable for smaller datasets and nonlinear relationships
  • Achieved R² Score: 0.964
  • Slightly higher prediction errors due to sensitivity to scaling and feature dimensions

2️⃣ Linear Regression (Final Model)

  • Assumes a linear relationship between predictors and target
  • More stable and interpretable
  • Achieved R² Score: 0.993 ✅
  • Selected as the final model for deployment due to:
    • Higher accuracy
    • Lower Mean Absolute Error (MAE) and RMSE
    • Consistent performance across validation splits

📈 Model Evaluation Metrics

Metric KNN Regressor Linear Regressor
R² Score 0.964 0.993
Mean Absolute Error (MAE) Higher Lower
Root Mean Squared Error (RMSE) Higher Lower

✅ Final Decision: Linear Regression selected as the deployed model.


💻 Tech Stack

  • Python
  • Streamlit (for web deployment)
  • scikit-learn
  • pandas, numpy, matplotlib, seaborn

🧪 Installation & Usage

1️⃣ Clone the Repository

git clone https://github.com/yourusername/Retail_Units_Sold_Prediction_App.git
cd Retail_Units_Sold_Prediction_App

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages