An end-to-end Data Analytics and Machine Learning project built using Python.
This project simulates a real-world retail sales workflow where raw sales data is:
- cleaned and transformed,
- analyzed for business insights,
- visualized using charts,
- and used for machine learning predictions.
The project demonstrates practical skills across:
- Data Engineering
- Data Analysis
- Data Visualization
- Machine Learning
Raw Sales Data
β
Data Cleaning & Transformation
β
Exploratory Data Analysis (EDA)
β
Business Insights & Visualization
β
Machine Learning Experiments
β
Prediction System
The dataset used in this project is intentionally small but raw and unclean.
This project was built primarily for learning purposes to understand real-world data workflows including:
- data cleaning,
- preprocessing,
- exploratory analysis,
- visualization,
- and machine learning pipelines.
The focus was on handling messy real-world issues such as:
- missing values,
- duplicates,
- inconsistent formatting,
- and invalid data types,
rather than building a production-scale model with a large dataset.
| File | Purpose |
|---|---|
Cleaning.py |
Cleans and transforms raw sales data |
Analysis.py |
Performs exploratory analysis and visualization |
FailML.py |
Initial ML attempt using static Revenue formula |
Prediction.py |
Final ML model for quantity prediction |
sales_raw.csv |
Raw messy dataset |
sales_cleaned.csv |
Cleaned dataset generated after preprocessing |
The raw dataset intentionally contained multiple real-world data issues to simulate industry-style preprocessing challenges.
Removed duplicate records based on Order_ID.
df.drop_duplicates(subset='Order_ID')Handled missing values in:
- City
- Price
- Quantity
- Date
Approaches used:
- Median imputation
- Group-based median transformation
- Row removal for invalid dates
- Default values where appropriate
Converted:
- Date β datetime
- Price β numeric
- Quantity β numeric
Used:
errors='coerce'to safely handle invalid values.
Standardized categorical columns using:
str.lower()This helped maintain consistency in:
- Product names
- Categories
- Cities
Removed:
- Negative prices
- Zero or invalid quantities
Applied business logic to ensure realistic data.
The dataset contained text values like:
"three"
Instead of blindly coercing them into NaN, they were manually mapped:
'three' β 3This preserved valid business information instead of losing data.
Created additional columns:
Revenue = Price Γ QuantityYearMonthMonth_Name
These features were later used for analysis and visualization.
Performed exploratory data analysis (EDA) to extract business insights from cleaned sales data.
Identified products generating the highest revenue.
- Bar Chart
Analyzed city-wise revenue contribution.
- Pie Chart
Studied monthly revenue patterns and seasonality.
- Line Chart
Compared contribution of each product category.
- Pie Chart
Beyond the initial requirements, additional business-oriented questions were analyzed:
Used filtered category-level aggregation to identify strongest electronics market.
Analyzed quantity-based demand rather than only revenue.
This helped distinguish:
- high-value products vs
- high-demand products
Used grouped monthly aggregation to identify peak business periods.
Examples of insights extracted:
- Highest revenue-driving product
- Strongest performing city
- Peak sales month
- Highest contributing category
These insights simulate real business reporting workflows.
An initial machine learning attempt was made to predict Revenue.
However, during experimentation it was realized that:
Revenue = Price Γ Quantity
This is a direct mathematical formula, not a hidden pattern.
Using Linear Regression on a deterministic formula does not represent meaningful machine learning.
- Revenue was already mathematically defined.
- The model was effectively learning multiplication.
- Predictions were not valuable from a business intelligence perspective.
This experiment was intentionally kept in the project to demonstrate:
- critical thinking,
- model evaluation,
- and understanding of when ML is appropriate.
A more meaningful ML problem was designed:
Predict Quantity using:
- Price
- Product
- Category
- City
Dataset split:
- 80% training
- 20% testing
Used:
train_test_split()Since ML models require numerical input:
Used:
OneHotEncoderColumnTransformer
to convert text categories into machine-readable features.
Implemented:
Pipeline()to automate:
- Encoding
- Preprocessing
- Model Training
This created a cleaner and production-style ML workflow.
Evaluated model performance using:
Measures average prediction error magnitude.
Measures how well the model explains data variance.
Generated:
- Actual vs Predicted Quantity plot
This helped visually inspect model performance.
Added interactive prediction functionality where users can enter:
- Price
- Product
- Category
- City
and receive predicted quantity output.
- Python
- Pandas
- NumPy
- Matplotlib
- Scikit-learn
- Data Cleaning
- Missing Value Handling
- Feature Engineering
- Data Transformation
- EDA
- Aggregation
- Visualization
- Business Insights
- Regression
- Encoding
- Pipelines
- Model Evaluation
Possible future enhancements:
- Larger datasets
- Power BI dashboard
- Time-series forecasting
- Advanced ML models
- Deployment using Flask/Streamlit
Simran
This project was built as a hands-on learning project to understand real-world data workflows from raw data to prediction systems.