Getaye/social-media-addiction-analyzer
📱 Social Media Addiction Risk Analyzer with AdaBoost
  
Machine Learning Course Project | COSC 6041 | College of Natural and Computational Sciences | Addis Ababa University
A production-ready web application that uses the AdaBoost (Adaptive Boosting) algorithm to predict social media addiction risk based on behavioral patterns. The model analyzes factors like daily usage, sleep patterns, mental health, and platform choice to classify users into Low, Moderate, or High risk categories.
🚀 Live Demo
Try the live application on Hugging Face Spaces: 
📌 Project Overview
- What is it? A web-based ML classifier that predicts social media addiction risk using behavioral patterns.
- Goal: Provide data-driven, personalized risk assessment and recommendations for digital wellness.
- Target Users: Students & young adults, researchers in digital wellness, mental health professionals, and the general public.
🌍 Problem Statement & Motivation
🧠 The AdaBoost Algorithm – Why It Fits
Adaptive Boosting is an ensemble method that combines many weak learners (decision stumps) into a strong classifier.
Mathematical Model
Initialize weights w_i = 1/N
For t = 1 to T (200 trees):
- Train weak learner on weighted data
- Compute error ε_t
- Assign weight α_t = ½·ln((1-ε_t)/ε_t)
- Increase weights of misclassified samples
Final: H(x) = sign(∑ α_t·h_t(x))Why AdaBoost for This Problem?
📊 The Dataset – 50,000 Synthetic Rows
A realistic dataset generated based on research thresholds:
Target Variable – Expert‑weighted Formula
total = usage_risk×2 + platform_risk×1.5 + experience_risk + sleep_risk + mental_risk
avg = total / 6.5
if avg > 2.3 → High risk
elif avg > 1.5 → Medium risk
else → Low riskClass distribution: Balanced (approx. 40% Low, 40% Medium, 20% High)
🔧 Feature Engineering & Weights
Input Features (7 raw → derived + platform dummies)
Platform Risk Mapping
⚙️ AdaBoost Hyperparameters & Training
Model Configuration (as implemented in app.py)
base_learner = DecisionTreeClassifier(max_depth=2, random_state=42)
model = AdaBoostClassifier(
estimator=base_learner,
n_estimators=200, # 200 weak learners
learning_rate=0.8, # shrinkage factor
random_state=42
)Training Process
- Load synthetic dataset (50k rows) or user-provided CSV
- Prepare features: numerical + one‑hot encoded platform dummies
- Split into training (80%) and testing (20%) – 40,000 training, 10,000 test.
- Train AdaBoost model on the training set and evaluate on the test set.
- The final production model is trained on all 50,000 rows to maximise performance, but the reported metrics come from the held‑out test set.Train AdaBoost model (fits all data)
📈 Adaptive Learning – Retraining with User Feedback
After every "Yes, Accurate" (like) feedback, the model is retrained on:
Synthetic dataset (50k) + all real “like” feedback- Immediate adaptation to real user patterns
- Synthetic dataset provides strong baseline knowledge
- Prevents overfitting to small real data
Admin Panel Features
- View all feedback (likes/unlikes)
- Monitor model performance history
- Manually trigger retraining
📊 Model Performance
Top 5 Most Important Features (from AdaBoost)
- Daily Usage Hours – strongest predictor
- Platform (TikTok) – high risk dummy
- Sleep Hours – deprivation increases risk
- Mental Health Score – lower = higher risk
- Usage Years – long‑term habituation
🖥️ User Interface & Features
🌐 Public Access (No Login)
- About App, Quick Test, Contact Admin, Login, Features, Get Help
👤 Registered User Features
- Risk Analyzer – full assessment with confidence & recommendations
- Usage Analytics – multi‑app logging, trends, work vs personal
- Personalized Recommendations – risk‑level specific advice
- My Profile – account statistics
- Submit Feedback – suggestions & bug reports
- My Activity – personal history
👑 Admin Features
- User Management – create users, grant admin
- Comments – moderate public inquiries
- Activity Log – all system activities, risk analyses, logins
- Model Feedback – view likes/unlikes, retrain model
🛠️ Technical Stack
- Frontend: Streamlit
- ML Algorithm: AdaBoost (scikit-learn)
- Base Estimator: Decision Tree (max_depth=2)
- Data Processing: Pandas, NumPy
- Visualization: Plotly
- Authentication: SQLite + hashlib
- Deployment: Hugging Face Spaces + GitHub Actions
📁 Project Structure
social-media-addiction-analyzer/
├── .github/workflows/deploy.yml # Auto-sync to HF
├── app.py # Streamlit application + model training & inference
├── requirements.txt # Dependencies
├── social_media_addiction_data.csv # Synthetic dataset (50k rows)
└── README.md # Project documentation🚀 Deployment & Achievements
Deployment Architecture
GitHub → GitHub Actions → Hugging Face Spaces (auto‑sync on push)
Achievements
✅ AdaBoost model with 200 estimators, 89% accuracy, retrains after every “like” ✅ 50,000‑row realistic dataset with expert‑weighted targets ✅ Full‑stack web app – authentication, analytics, admin panel ✅ Live on Hugging Face – accessible to everyone
🧪 Run Locally (GitHub Codespaces)
# Install dependencies
pip install streamlit pandas numpy plotly scikit-learn joblib
# Run the app
streamlit run app.py📄 License
MIT License – free for academic and research use.
👨💻 Author
Getaye Fiseha (GSE/6132/18) MSc in Computer Science (Network & Security) Machine Learning Course (CoSc 6041) – Submitted to Dr. Yaregal A. Addis Ababa University, Ethiopia
🙏 Acknowledgements
- scikit-learn for AdaBoost implementation
- Streamlit for rapid UI development
- Hugging Face for free hosting
- Academic references (Freund & Schapire 1997; Andreassen et al. 2016)
Questions? Feel free to open an issue on GitHub or contact the author.
