An interactive machine learning dashboard that predicts smartphone purchasing behavior
based on demographic factors, user preferences, and market trends.
|
|
| Section | Description |
|---|---|
| Overview | Project metrics, model performance summary, and quick stats |
| Demographics | Interactive demographic analysis with purchase patterns by age, gender, income |
| Prediction Tool | Real-time ML predictions with user demographic input |
| Brand Comparison | Comprehensive brand analysis, market share, and loyalty metrics |
| Insights | Advanced analytics, user segments, and business intelligence |
| Documents | Access reports, notebooks, and project documentation |
- โ 87%+ Prediction Accuracy with optimized Random Forest
- โ Interactive Visualizations using Chart.js
- โ Real-time Predictions with instant probability scores
- โ Brand Intelligence with market share analysis
- โ Export Functionality for charts and data
- โ Mobile Responsive design for all devices
- โ Dark Mode with smooth animations
- โ PWA Support with offline capabilities
|
Python |
Flask |
Scikit-learn |
HTML5 |
CSS3 |
JavaScript |
Azure |
| Layer | Technologies |
|---|---|
| Backend | Python 3.11, Flask 2.2.5, Flask-CORS, Gunicorn |
| ML/Data | Scikit-learn 1.7.1, Pandas 2.3.2, NumPy 2.3.3, Joblib |
| Frontend | HTML5, CSS3, JavaScript ES6+, Bootstrap 5 |
| Visualization | Chart.js 4.x, Custom animations |
| Deployment | Azure App Service, Gunicorn WSGI |
๐ https://smartpredict-app-a3gcecfectcudbdd.centralindia-01.azurewebsites.net
# Clone the repository
git clone https://github.com/Mandar123454/Predictive-Modeling-for-Smartphone-Purchase-Behavior-ML.git
cd Predictive-Modeling-for-Smartphone-Purchase-Behavior-ML
# Create virtual environment
python -m venv .venv
# Activate virtual environment
# Windows:
.venv\Scripts\activate
# Linux/Mac:
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Run the dashboard
python run_dashboard.pyThen open http://localhost:5000 in your browser.
# Just run the setup script
.\setup.bat๐ฆ SmartPredict
โโโ ๐ app.py # Root entry point
โโโ ๐ run_dashboard.py # Cross-platform launcher
โโโ ๐ requirements.txt # Python dependencies
โโโ ๐ Procfile # Azure/Heroku deployment
โ
โโโ ๐ Dashboard/ # Web application
โ โโโ ๐ app.py # Flask backend & API
โ โโโ ๐ index.html # Main dashboard UI
โ โโโ ๐ css/ # Stylesheets (dark mode, animations)
โ โโโ ๐ js/ # JavaScript modules & charts
โ โโโ ๐ data/ # Static visualization data
โ
โโโ ๐ Data/ # ML datasets
โ โโโ ๐ smartphone_purchased_data.csv
โ โโโ ๐ smartphone_purchased_data_cleaned.csv
โ โโโ ๐ smartphone_purchased_data_updated.csv
โ
โโโ ๐ Models/ # Trained ML models
โ โโโ ๐ model.pkl # Random Forest model
โ โโโ ๐ scaler.pkl # Feature scaler
โ โโโ ๐ model_columns.pkl # Column mappings
โ
โโโ ๐ Notebook/ # Jupyter notebooks
โ โโโ ๐ Main Notebook.ipynb
โ โโโ ๐ exploratory_analysis.ipynb
โ โโโ ๐ feature_influence_analysis.ipynb
โ
โโโ ๐ Project Report/ # Documentation
โโโ ๐ DOCS.md
โโโ ๐ PROJECT_OVERVIEW_ALL_IN_ONE.md
This project is Azure App Service ready with included Procfile and Gunicorn configuration.
# Quick deploy with Azure CLI
az webapp up --name your-app-name --resource-group your-rg --runtime "PYTHON:3.11"๐ See AZURE_DEPLOY.md for detailed deployment guide.
|
|
| Endpoint | Method | Description |
|---|---|---|
/api/status |
GET | Health check & API status |
/api/data |
GET | Dataset statistics |
/api/feature_importance |
GET | Model feature importance |
/api/predict |
POST | Purchase prediction |
/api/compare_brands |
POST | Brand comparison |
/api/segment_analysis |
GET | User segment analysis |
import requests
response = requests.post('http://localhost:5000/api/predict', json={
'age': 28,
'gender': 'Male',
'income': 65000,
'education': "Bachelor's"
})
print(f"Purchase Probability: {response.json()['probability']}%")Issue: "Python not found"
# Solution: Install Python from python.org
# Verify installation:
python --version
# or
python3 --versionIssue: "Module not found" errors
# Solution: Install missing dependencies
pip install flask flask-cors pandas numpy scikit-learn
# Or reinstall all requirements
pip install -r requirements.txtIssue: "Port 5000 already in use"
# Solution 1: Kill the process using port 5000
# Windows:
netstat -ano | findstr :5000
taskkill /PID <PID_NUMBER> /F
# Linux/Mac:
lsof -ti:5000 | xargs kill -9
# Solution 2: Use a different port
# Edit Dashboard/app.py and change:
# app.run(host='0.0.0.0', port=5001, debug=True)Issue: "Model files not found"
# The dashboard will run in demo mode
# This is normal and provides sample predictions
# Real models will be loaded if present in Models/ folderIssue: Dashboard loads but charts don't appear
# Solution: Clear browser cache and refresh
# Or try in an incognito/private browsing window- Age Analysis: View purchase patterns across age groups
- Income Impact: See how income affects buying decisions
- Gender Insights: Compare male vs female purchasing behavior
- Education Correlation: Analyze education level impacts
- Input Demographics: Age, gender, income, education
- Set Preferences: Brand, price range, feature priorities
- Get Predictions: Real-time purchase probability (0-100%)
- Understand Why: See which factors influence the prediction
- Market Share: View brand popularity over time
- Loyalty Analysis: See which brands retain customers best
- Feature Comparison: Compare what each brand offers
- Demographic Preferences: See which age groups prefer which brands
- User Segments: Discover different customer types
- Price Sensitivity: Understand how price affects purchases
- Seasonal Trends: See when people buy phones most
- Feature Importance: Learn which features matter most
- Prediction Speed: < 100ms average response time
- Model Accuracy: 87.3% on test data
- Data Size: 10,000+ smartphone purchase records
- Features: 18 engineered features for prediction
- Browser Compatibility: All modern browsers supported
- Mobile Responsive: Works on phones and tablets
When running locally, the following REST API endpoints are available:
GET /api/status- Check API health and statusGET /api/data- Basic dataset statistics and distributionsGET /api/feature_importance- Model feature importance (or fallback)POST /api/predict- Purchase prediction for user inputPOST /api/compare_brands- Compare probabilities across brandsGET /api/segment_analysis- Segment analysis by age, income, brand
import requests
# Get a prediction
response = requests.post('http://localhost:5000/api/predict', json={
'age': 28,
'gender': 'Male',
'income': 65000,
'education': "Bachelor's"
})
prediction = response.json()
print(f"Purchase Probability: {prediction['probability']}%")- Source: Synthetic smartphone purchase behavior data
- Size: 10,841 records with 18 features
- Target: Binary classification (Will Purchase: Yes/No)
- Features: Demographics, financial, behavioral, and preference data
- Data Preprocessing: Missing value imputation, outlier detection
- Feature Engineering: Create derived features, categorical encoding
- Model Training: Random Forest with hyperparameter tuning
- Validation: 10-fold cross-validation, train-test split
- Evaluation: Accuracy, Precision, Recall, F1-Score, ROC-AUC
- Overall Accuracy: 87.3%
- Precision: 85.1% (true positive rate)
- Recall: 89.7% (sensitivity)
- F1-Score: 87.3% (harmonic mean of precision/recall)
- ROC-AUC: 0.924 (excellent discrimination)
- One-File Overview:
Project Report/PROJECT_OVERVIEW_ALL_IN_ONE.md - Technical Documentation:
Project Report/DOCS.md - Full ML Report (PDF):
Project Report/ML Report MK.pdf
This project is perfect for:
- Machine Learning Students: Learn end-to-end ML project development
- Data Science Courses: Understand feature engineering and model evaluation
- Business Analytics: See how ML applies to real-world business problems
- Web Development: Learn Flask backend with interactive frontend integration
# Fork the repository on GitHub
git clone https://github.com/YOUR-USERNAME/Predictive-Modeling-for-Smartphone-Purchase-Behavior-ML.git
cd Predictive-Modeling-for-Smartphone-Purchase-Behavior-ML
# Create virtual environment (recommended)
python -m venv smartpredict_env
source smartpredict_env/bin/activate # Linux/Mac
# or
smartpredict_env\Scripts\activate # Windows
# Install development dependencies
pip install -r requirements.txt
pip install pytest flask-testing jupyter
# Run tests
python -m pytest
# Start development server
python run_dashboard.py- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Make your changes and add tests
- Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Model Enhancement: Improve prediction accuracy
- New Visualizations: Add more interactive charts
- UI/UX Improvements: Enhance user interface
- Performance Optimization: Speed up loading times
- Mobile Experience: Improve responsive design
- Documentation: Expand guides and tutorials
This project is licensed under the MIT License - see the LICENSE file for details.
If you reuse or modify this project (commercially or nonโcommercially) you must:
- Retain the original copyright notice:
Copyright (c) 2025 Mandar123454 - Keep the MIT license text in your distribution (LICENSE file)
- Clearly document any major modifications you make
Recommended (not legally required under MIT):
- Link back to this repository so others can find the source
- Add a short note like: โBased on SmartPredict โ Smartphone Purchase Prediction Dashboard (MIT Licensed)โ
No warranties are provided; see โAS ISโ clause in the license. Use at your own risk.
By submitting a Pull Request you agree your contribution is provided under the same MIT License and that you have the right to license it. If you include thirdโparty code, ensure its license is compatible and note it in a new THIRD_PARTY_NOTICES section or file.
The repository may include (or you can add):
NOTICEโ Highโlevel copyright + license pointer (for downstream bundlers)CONTRIBUTING.mdโ How to propose changes, coding standards, and review process
If these files appear later, they will complement (not replace) the MIT terms.
Need help? Here's how to get support:
- Check the Troubleshooting Section above
- Review Documentation: See Project Report/DOCS.md
- GitHub Issues: Open an issue for bugs or feature requests
- Discussions: Use GitHub Discussions for questions
Made with โค๏ธ by the SmartPredict Team
Helping businesses make data-driven decisions about smartphone market trends.