This project implements a full-stack AI application designed to predict developer salaries based on various factors, leveraging the Stack Overflow Developer Survey 2024 dataset. The application features a robust Flask backend for machine learning predictions and a modern React frontend for user interaction and visualization.
- Salary Prediction: Predicts annual developer salaries (
ConvertedCompYearly) based on user-provided inputs. - Intuitive User Interface: A multi-step form built with React,
shadcn/ui, and Tailwind CSS for a seamless experience. - Data Visualization: Displays prediction results alongside insightful charts:
- Feature Importance Chart: Visualizes the most influential factors in salary prediction.
- Salary Distribution Chart: Shows how the predicted salary fits within the overall distribution.
- Robust Backend: A Flask API serving machine learning models, preprocessors, and data.
- Pre-trained Models: Utilizes an ensemble of pre-trained machine learning models for high-accuracy predictions.
- Framework: Flask
- Language: Python 3.13.4
- Machine Learning:
scikit-learn(for preprocessing and base models)LightGBM(Best performing model)XGBoostCatBoostmlxtend(for ensemble/meta-regressor)joblib(for model persistence)
- Data Handling:
pandas,numpy - API Server: Gunicorn
- Data Visualization (Backend-generated plots):
matplotlib,seaborn,plotly,graphviz
- Framework: React (with Vite)
- UI Components:
shadcn/ui(built on Radix UI) - Styling: Tailwind CSS
- Form Management: React Hook Form (with Zod for validation)
- Animation: Framer Motion
- API Communication: Axios
- Charting: Recharts
| Component | Technologies/Packages |
|---|---|
| Framework | Flask 2.3.3 |
| Machine Learning | LightGBM 4.6.0, XGBoost 3.0.2 |
| CatBoost 1.2.8, scikit-learn 1.7.1 | |
| Data Processing | pandas 2.3.0, numpy 2.3.1 |
| Visualization | matplotlib 3.10.3, plotly 6.2.0 |
| seaborn 0.13.2, graphviz 0.21 | |
| Server | Gunicorn 21.2.0 |
| Component | Technologies/Packages |
|---|---|
| Framework | React 19 + Vite 7.0.4 |
| UI Components | shadcn/ui |
| Styling | Tailwind CSS 4.1.11 |
| Form Management | React Hook Form 7.61.1 + Zod 4.0.10 |
| Charts | Recharts 3.1.0 |
| Animation | Framer Motion 12.23.9 |
| Icons | Lucide React 0.526.0 |
.
├── backend/ # Backend server and ML components
│ ├── app/ # Flask application core
│ │ ├── routes/ # API endpoint definitions
│ │ │ ├── __init__.py
│ │ │ └── prediction.py # Salary prediction API
│ │ ├── services/ # Business logic
│ │ │ ├── __init__.py
│ │ │ └── prediction_service.py
│ │ ├── __init__.py
│ │ └── config.py # Configuration settings
│ ├── data/ # Survey datasets
│ │ ├── 2024 Developer Survey.pdf
│ │ ├── survey_results_processed.csv
│ │ ├── survey_results_public.csv
│ │ └── survey_results_schema.csv
│ ├── model_artifacts/ # Trained models and pipelines
│ │ ├── eda_plots/ # Exploratory analysis (155 files)
│ │ ├── best_model_lightgbm.joblib
│ │ ├── best_model_xgboost.joblib
│ │ ├── best_salary_prediction_pipeline.joblib
│ │ └── ... # Other model artifacts
│ ├── plots/ # Training visualizations (20 files)
│ ├── scripts/ # Data processing scripts
│ │ ├── explore_data.py
│ │ ├── prepare_data.py
│ │ └── train_model.py
│ ├── .gitignore
│ ├── requirements.txt # Python dependencies
│ └── run.py # Application entry point
├── frontend/ # React UI components
│ ├── public/ # Static assets
│ ├── src/
│ │ ├── assets/ # Default assets
│ │ ├── components/
│ │ │ ├── steps/ # Form wizard components
│ │ │ │ ├── Step1.jsx
│ │ │ │ ├── Step2.jsx
│ │ │ │ └── Step3.jsx
│ │ │ ├── ui/ # shadcn/ui components
│ │ │ │ ├── accordion.jsx
│ │ │ │ ├── button.jsx
│ │ │ │ └── ... # Other UI components
│ │ │ ├── ResultDisplay.jsx # Prediction results view
│ │ │ └── SalaryPredictor.jsx # Main form component
│ │ ├── lib/ # Utilities and schemas
│ │ │ ├── data.js # Form options data
│ │ │ ├── schema.js # Validation schemas
│ │ │ └── utils.js # Helper functions
│ │ ├── App.jsx # Root component
│ │ ├── App.css
│ │ └── main.jsx # Application entry
│ ├── .gitignore
│ ├── package.json # Frontend dependencies
│ └── vite.config.js # Build configuration
├── .gitattributes # Git LFS configuration
└── README.md # Project documentation
This project utilizes Git Large File Storage (Git LFS) for managing large machine learning model and dataset files. Please ensure you have Git LFS installed before cloning the repository.
- Git: Download & Install Git
- Git LFS: Download & Install Git LFS
- After installation, run in your terminal:
git lfs install
- After installation, run in your terminal:
- Python: Version 3.13.4 (or compatible 3.x) Download Python
- Node.js: Version v22.17.1 (or compatible 20+) Download Node.js (includes npm)
npm: Version 10.9.2 (comes with Node.js)
- Clone the repository:
Git LFS will automatically download the large files (like
git clone [https://github.com/harman-04/ml-salary-prediction.git](https://github.com/harman-04/ml-salary-prediction.git) cd ml-salary-predictionsurvey_results_public.csvand.joblibmodels) during the cloning process.
- Navigate to the backend directory:
cd backend - Create and activate a Python virtual environment:
It's highly recommended to use a virtual environment to manage dependencies for your Python projects.
- Create virtual environment:
python -m venv venv
- Activate virtual environment:
- On Windows (Command Prompt/PowerShell):
.\venv\Scripts\activate
- On macOS/Linux (Bash/Zsh):
bash source venv/bin/activate(You'll see(venv)prepended to your terminal prompt, indicating the virtual environment is active.)
- On Windows (Command Prompt/PowerShell):
- Create virtual environment:
- Install Python dependencies:
pip install -r requirements.txt
- Run the Flask backend application:
The backend server will start and typically run on
python run.py
http://127.0.0.1:5000. Keep this terminal window open.
-
Open a new terminal window.
-
Navigate to the frontend directory: (Assuming you are in the project root
D:\salary-prediction-ai)cd frontend -
Install Node.js dependencies:
npm install
-
Run the React frontend application:
npm run dev
The frontend development server will start and typically open in your browser at
http://localhost:5173.
Once both the backend and frontend servers are running:
- Open your web browser and navigate to
http://localhost:5173. - Fill in the multi-step form with the required developer details (Age, Country, Org Size, Employment, Education Level, Dev Type, Remote Work, Job Satisfaction, Knowledge Frequency).
- Select relevant tech skills across various categories (Language, Database, Platform, Webframe, MiscTech, ToolsTech, NEWCollabTools, OfficeStackAsync, OfficeStackSync, AISearchDev, AITool).
- Submit the form to get an instant salary prediction.
- View the predicted annual salary along with dynamically generated "Feature Importance Chart" and "Salary Distribution Chart."
The project uses the stackoverflow-developer-survey-2024 dataset to predict ConvertedCompYearly. Various machine learning models were trained and evaluated:
- Best Model: LightGBM (R2 Score: 0.734)
- Other Models Compared:
- Random Forest (R2 Score: 0.703)
- XGBoost (R2 Score: 0.732)
- CatBoost (R2 Score: 0.727)
- HistGradientBoosting (R2 Score: 0.725)
The model_artifacts folder contains the saved preprocessor and trained models, including the best-performing LightGBM model and the full prediction pipeline. The plots folder contains visual comparisons of algorithm results and actual vs. prediction plots from the training phase.
Contributions are welcome! Please feel free to open issues or submit pull requests.