Skip to content

didark90/Retail-Prices

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

600 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Retail Price Optimization Dashboard

Streamlit Python FastAPI License

A comprehensive, production-ready retail price optimization dashboard with machine learning models, price prediction, competitor analysis, and dynamic pricing strategies.

✨ Features

πŸ“Š Dashboard Capabilities

  • Interactive Visualizations: Multiple chart types including histograms, box plots, scatter plots, correlation heatmaps
  • Real-time Price Prediction Calculator: Input product parameters for instant predictions
  • Advanced Analytics Dashboard: KPI metrics, market analysis, and data exploration tools
  • Export & Reporting: Download filtered data in CSV, Excel, or JSON format

πŸ€– Machine Learning Models

  • Decision Tree Regressor
  • Random Forest Regressor
  • Gradient Boosting Regressor
  • Linear/Ridge/Lasso Regression
  • Model evaluation with multiple metrics (RΒ², RMSE, MAE, MAPE)
  • Cross-validation support
  • Feature importance analysis

πŸ’° Price Optimization

  • Multiple Pricing Strategies:
    • Cost-plus pricing
    • Competitor-based pricing
    • Value-based pricing
    • Dynamic pricing
    • Penetration pricing
    • Price skimming
  • Price elasticity analysis
  • Competitive position analysis
  • Profit margin optimization

πŸ“ˆ Analytics Engine

  • Statistical analysis (descriptive stats, correlations, hypothesis testing)
  • Trend analysis and forecasting
  • Category performance metrics
  • Customer behavior analysis
  • Product segmentation

πŸ”Œ API Endpoints

  • RESTful API with FastAPI
  • Price prediction endpoint
  • Optimization endpoints
  • Batch processing support
  • Health monitoring

πŸ—οΈ Project Structure

Retail-Prices/
β”œβ”€β”€ app.py                    # Main Streamlit application
β”œβ”€β”€ Optimized.py              # Enhanced Streamlit dashboard
β”œβ”€β”€ config.py                 # Configuration settings
β”œβ”€β”€ data_validation.py        # Data validation utilities
β”œβ”€β”€ retail_price.csv          # Dataset
β”œβ”€β”€ requirements.txt          # Python dependencies
β”œβ”€β”€ Dockerfile                # Docker configuration
β”œβ”€β”€ docker-compose.yml        # Docker Compose setup
β”‚
β”œβ”€β”€ models/                   # Machine Learning Models
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ price_predictor.py    # Price prediction models
β”‚   β”œβ”€β”€ model_evaluator.py    # Model evaluation tools
β”‚   └── feature_importance.py # Feature importance analysis
β”‚
β”œβ”€β”€ utils/                    # Utility Modules
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ price_optimizer.py    # Price optimization engine
β”‚   β”œβ”€β”€ data_preprocessing.py # Data preprocessing utilities
β”‚   β”œβ”€β”€ analytics.py          # Analytics engine
β”‚   β”œβ”€β”€ visualizations.py     # Chart building utilities
β”‚   β”œβ”€β”€ logger.py             # Logging configuration
β”‚   β”œβ”€β”€ database.py           # Database connector
β”‚   └── report_generator.py   # Report generation
β”‚
β”œβ”€β”€ api/                      # API Module
β”‚   └── main.py               # FastAPI endpoints
β”‚
β”œβ”€β”€ pages/                    # Streamlit Pages
β”‚   β”œβ”€β”€ 1_πŸ“¦_Inventory_Analysis.py
β”‚   β”œβ”€β”€ 2_πŸ“ˆ_Sales_Forecast.py
β”‚   └── 3_πŸͺ_Competitor_Analysis.py
β”‚
β”œβ”€β”€ tests/                    # Test Suite
β”‚   β”œβ”€β”€ conftest.py           # Pytest configuration
β”‚   └── test_modules.py       # Unit tests
β”‚
└── .github/                  # GitHub Actions
    └── workflows/
        └── ci.yml            # CI/CD pipeline

πŸš€ Quick Start

Prerequisites

  • Python 3.9 or higher
  • pip package manager

Installation

  1. Clone the repository
git clone https://github.com/kamrankamrankhan/Retail-Prices.git
cd Retail-Prices
  1. Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Run the Streamlit app
streamlit run app.py
  1. Run the FastAPI server (optional)
uvicorn api.main:app --reload --port 8000

Docker Deployment

# Build and run with Docker Compose
docker-compose up -d

# Access the dashboard
# Streamlit: http://localhost:8501
# API: http://localhost:8000

πŸ“Š Usage

Price Prediction

from models.price_predictor import PricePredictor
import pandas as pd

# Load data
data = pd.read_csv('retail_price.csv')
data['comp_price_diff'] = data['unit_price'] - data['comp_1']

# Initialize and train model
predictor = PricePredictor(model_type='random_forest')
predictor.fit(data)

# Make prediction
predicted_price = predictor.predict_single(
    qty=100,
    unit_price=50.0,
    comp_price=45.0,
    product_score=4.5
)
print(f"Predicted Price: ${predicted_price:.2f}")

Price Optimization

from utils.price_optimizer import PriceOptimizer, PricingStrategy
import pandas as pd

data = pd.read_csv('retail_price.csv')
optimizer = PriceOptimizer(data)

# Optimize price using competitor-based strategy
result = optimizer.optimize_price(
    product_id='bed1',
    strategy=PricingStrategy.COMPETITOR_BASED,
    position='competitive'
)

print(f"Optimal Price: ${result.optimal_price}")
print(f"Expected Revenue: ${result.expected_revenue}")

Data Preprocessing

from utils.data_preprocessing import DataPreprocessor

preprocessor = DataPreprocessor(data)
preprocessor.remove_duplicates()\
    .handle_missing_values(strategy='mean')\
    .remove_outliers(method='iqr')\
    .create_features()

processed_data = preprocessor.get_processed_data()

πŸ”Œ API Endpoints

Endpoint Method Description
/ GET API info
/health GET Health check
/predict POST Price prediction
/optimize POST Price optimization
/optimize/batch POST Batch optimization
/products GET List products
/categories GET List categories
/analytics/summary GET Analytics summary

Example API Request

# Predict price
curl -X POST "http://localhost:8000/predict" \
  -H "Content-Type: application/json" \
  -d '{
    "qty": 100,
    "unit_price": 50.0,
    "comp_1": 45.0,
    "product_score": 4.5
  }'

πŸ§ͺ Testing

# Run all tests
pytest tests/ -v

# Run with coverage
pytest tests/ -v --cov=. --cov-report=html

# Run specific test file
python tests/test_modules.py

πŸ“ˆ Dashboard Pages

  1. Main Dashboard (app.py) - Core analytics and visualizations
  2. Inventory Analysis - Stock levels and product performance
  3. Sales Forecast - Predictive sales analytics
  4. Competitor Analysis - Market position comparison

πŸ› οΈ Configuration

Edit config.py to customize:

# Application settings
APP_TITLE = "Retail Price Analytics Dashboard"
DATA_FILE = "retail_price.csv"

# Model settings
DEFAULT_TEST_SIZE = 20
DEFAULT_RANDOM_STATE = 42

# Data validation thresholds
MAX_PRICE_THRESHOLD = 10000
MIN_QUALITY_SCORE = 70

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Streamlit for the amazing dashboard framework
  • Scikit-learn for machine learning utilities
  • Plotly for interactive visualizations
  • FastAPI for the high-performance API framework

πŸ“ž Support

For issues and feature requests, please use the GitHub Issues page.


Built with ❀️ for Retail Analytics

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Jupyter Notebook 91.9%
  • Python 7.5%
  • PowerShell 0.6%
  • Batchfile 0.0%
  • Shell 0.0%
  • Dockerfile 0.0%