Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available: 6.13.0
MLPayGrade Advanced Salary Predictor - Hugging Face Spaces Deployment
π Quick Deploy to Hugging Face Spaces
This repository contains everything needed to deploy your MLPayGrade salary prediction model on Hugging Face Spaces.
π Files Structure
Deployment Files/
βββ app.py # Main Gradio app for Hugging Face
βββ requirements.txt # Python dependencies
βββ best_model.pkl # Trained LightGBM model
βββ scaler.pkl # Feature scaler
βββ feature_names.json # Feature names list
βββ deployment_functions.pkl # Feature engineering functions
βββ shap_explainer.pkl # SHAP explainer
βββ shap_importance.json # Feature importance rankings
π― Model Information
- Algorithm: LightGBM Regressor
- Features: 85 Clean Features (No Data Leakage)
- Performance: RΒ² = 0.2848, MAE = $44,323.68, RMSE = $64,868.74
- Data: 2024 ML/AI Job Market Data
- Validation: Honest Performance (Corrected for Data Leakage)
π Deployment Steps
1. Create Hugging Face Account
- Go to huggingface.co
- Sign up for a free account
2. Create New Space
- Click "New Space" button
- Choose "Gradio" as the SDK
- Set visibility (Public or Private)
- Choose a license
3. Upload Files
- Upload all files from the
Deployment Files/folder - Make sure
app.pyis in the root directory - Upload model files (
*.pkl,*.json)
4. Automatic Deployment
- Hugging Face will automatically install dependencies from
requirements.txt - The app will be available at:
https://huggingface.co/spaces/YOUR_USERNAME/SPACE_NAME
π§ Features
Job Configuration
- Job Title: Data Scientist, ML Engineer, AI Engineer, Data Engineer, Data Analyst
- Experience Level: Entry, Mid, Senior, Executive
- Company Size: Small (<50), Medium (50-250), Large (>250)
- Employment Type: Full-time, Part-time, Contract, Freelance
- Location: US, CA, GB, AU, DE, FR, etc.
- Remote Work: On-site, Hybrid, Remote
Model Outputs
- Predicted Salary: Annual salary in USD
- Detailed Explanation: Feature breakdown and model information
- What-If Analysis: Interactive parameter exploration
π Model Performance
| Metric | Value | Status |
|---|---|---|
| RΒ² Score | 0.2848 | β Honest |
| MAE | $44,323.68 | β Realistic |
| RMSE | $64,868.74 | β Appropriate |
| Data Leakage | None | β Clean |
π― Key Advantages
- No Data Leakage: All features are legitimate and domain-driven
- Honest Performance: Realistic RΒ² score reflects true predictive power
- Clean Architecture: Proper train-test separation
- Domain Knowledge: Features based on industry understanding
- Interactive UI: User-friendly Gradio interface
π Technical Details
Feature Engineering
- Ordinal Encodings: Experience level, company size, employment type
- Interaction Features: Experience Γ Size, Experience Γ Remote, Size Γ Remote
- Geographic Features: Country-based location encoding
- Complexity Features: Job title word count, location diversity
Model Architecture
- Algorithm: LightGBM (Gradient Boosting)
- Preprocessing: RobustScaler for feature scaling
- Validation: Proper train-test split (no data leakage)
- Explainability: SHAP analysis ready
π Access Your Deployed App
Once deployed, your app will be available at:
https://huggingface.co/spaces/YOUR_USERNAME/MLPayGrade-Salary-Predictor
π Usage Examples
Example 1: Senior Data Scientist
- Job Title: "Data Scientist"
- Experience: Senior Level
- Company Size: Large
- Location: US
- Remote: Hybrid
- Predicted: ~$180,000
Example 2: Entry ML Engineer
- Job Title: "ML Engineer"
- Experience: Entry Level
- Company Size: Medium
- Location: CA
- Remote: On-site
- Predicted: ~$95,000
π Benefits of Hugging Face Deployment
- Reliability: Always available, no local setup needed
- Scalability: Handles multiple users simultaneously
- Sharing: Easy to share with stakeholders
- Updates: Simple to update and redeploy
- Professional: Looks professional for presentations
π§ Troubleshooting
Common Issues
- Model Loading Error: Ensure all
.pklfiles are uploaded - Dependency Issues: Check
requirements.txtcompatibility - Memory Limits: Free tier has 16GB RAM limit
- File Size: Ensure model files are under space limits
Solutions
- Verify Files: Check all required files are present
- Update Dependencies: Use compatible package versions
- Optimize Model: Reduce model size if needed
- Check Logs: Use Hugging Face logs for debugging
π Support
For deployment issues:
- Check Hugging Face documentation
- Review error logs in your Space
- Verify all files are properly uploaded
- Ensure dependencies are compatible
MLPayGrade Advanced Track - Built with excellence and honesty! π―