Overview
This is a machine learning app for salary prediction. It is a simple app that uses machine learning to predict the salary of a person based on his/her years of experience. The app is built using python and the machine learning model is built using the scikit-learn library.
Tools
-
Python (Marchine Learning & Backend): Python is a programming language that lets you work quickly and integrate systems more effectively. It is used for machine learning and backend development in this project.
-
Next.js (Frontend): Next.js is an open-source development framework built on top of Node.js enabling React based web applications functionalities such as server-side rendering and generating static websites.
Resources
- Dataset: Salary_Data.csv
Data Preprocessing
-
Data Cleaning: The data is cleaned by removing the rows with missing values.
-
Data Encoding: The data is encoded using the
LabelEncoderclass from thesklearn.preprocessingmodule. -
Class Binding: Initially, the data is bound into multiple classes using the
KBinsDiscretizerclass from thesklearn.preprocessingmodule. However, the results were not satisfactory, so we manually bind the classes to achieve better results. -
Data Balancing: The data is balanced using the
RandomUnderSamplerclass from theimblearn.under_samplingmodule. -
Data Splitting: The data is split into training and testing sets.
Model
we train our model with five different algorithms and compare their results. The algorithms are:
-
KNN: K-Nearest Neighbors, it is our baseline model.
-
Decision Tree
-
QDA (Quadratic Discriminant Analysis)
-
Naive Bayes
-
MLP (Multi-Layer Perceptron)
Results
The results of the five algorithms are as follows:
| Algorithm | Accuracy | Precision | Recall | F1 Score |
|---|---|---|---|---|
| KNN | 0.33 | 0.35 | 0.39 | 0.35 |
| Decision Tree | 0.35 | 0.31 | 0.30 | 0.32 |
| QDA | 0.34 | |||
| Naive Bayes | 0.36 | |||
| MLP | 0.56 |
Frontend & Backend Development
The frontend and backend of the app is developed using Next.js and Python respectively. The frontend is developed using the create-next-app command and the backend is developed using the flask module.
Responsible for the project
I was responsible for the frontend development, training the KNN algorithm, and working on data processing.
Conclusion
Although the results are acceptable, they are not satisfactory for production use. The model's accuracy can be improved by incorporating more data and utilizing more advanced algorithms. The amount and quality of data are crucial factors that impact the accuracy of the model.
Note: The dataset is generated using python faker library.
Screenshots
Landing page
Sending request to server for prediction
Results

