Skip to content

Shreyanshg11/CodeAlpha_SalesPrediction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodeAlpha_SalesPrediction

Sales prediction using Linear Regression and Random Forest with advertising channel impact analysis.

Sales Prediction using Python 📈

Project Overview

Sales prediction using Linear Regression and Random Forest with advertising channel impact analysis.

Dataset Information

  • Total Records: 200
  • Source: Kaggle — Advertising Dataset

Features in Dataset

  • TV (Advertising Budget in thousands)
  • Radio (Advertising Budget in thousands)
  • Newspaper (Advertising Budget in thousands)
  • Sales (Target Variable in thousands)

Technologies Used

  • Python
  • Pandas
  • NumPy
  • Matplotlib
  • Seaborn
  • Scikit-Learn

Project Workflow

  1. Data Loading
  2. Data Exploration
  3. Data Visualization
  4. Train-Test Split
  5. Model Training
  6. Model Evaluation & Comparison
  7. Actual vs Predicted Analysis
  8. Channel Impact Analysis
  9. Feature Importance Analysis
  10. New Sales Prediction
  11. Key Insights Summary

Visualizations Created

  • Sales Distribution
  • Advertising Budget Distribution
  • Advertising Channels vs Sales Scatter Plots
  • Correlation Heatmap
  • Pairplot of All Features
  • Actual vs Predicted Comparison Plot
  • Channel Impact Bar Chart
  • Feature Importance Bar Chart

Machine Learning Models Used

Model 1: Linear Regression Model 2: Random Forest Regressor

  • n_estimators = 100
  • random_state = 42

Results

Metric Linear Regression Random Forest
R² Score 89.94% 98.13%
RMSE 1.78 0.77
MAE 1.46 0.62

Sample Prediction

  • TV Budget: $200,000
  • Radio Budget: $40,000
  • Newspaper Budget: $50,000
  • Linear Regression Prediction: 19.63k units
  • Random Forest Prediction: 20.26k units

Key Insights

  • Random Forest outperformed Linear Regression (98.13% vs 89.94%)
  • TV is the most impactful advertising channel on sales
  • Newspaper has the least impact on sales
  • Average sales across all records is 14.02k units
  • Increasing TV budget has the strongest positive effect on sales
  • Radio shows moderate correlation with sales

How to Run

  1. Clone this repository
  2. Install required libraries:
pip install pandas numpy matplotlib seaborn scikit-learn
  1. Open the notebook in Jupyter:
jupyter notebook sales_prediction.ipynb
  1. Run all cells sequentially

Author

Shreyansh Gupta B.Tech (CSDS) — Galgotias College of Engineering & Technology

About

Sales prediction using Linear Regression and Random Forest with advertising channel impact analysis.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages