Skip to main content

Salary Prediction Web App using Streamlit

Salary Prediction Web App

In this article, we are going to discuss how to predict the salary based on various attributes related to salary  using Random Forest Regression.

This study focuses on a system that predicts the salary of a candidate based on candidate’s qualifications, historical data, and work experience. This app uses a machine learning algorithm to give the result.

The algorithm used is Random Forest Regression. In this problem, the target variable (or output), y, takes value of salary for a given set of input features (or inputs), X. The dataset contains gender, secondary school percentage, higher secondary school percentage, higher secondary school stream, degree percentage, degree type, work experience and specialization of candidate.


Below is the step-by-step Approach:

Step 1: Import the necessary modules and read the dataset we are going to use for this analysis. Below is a screenshot of the dataset we used in our analysis.
Dataset for machine learning web application

Step 2: Now before moving forward we need to pre-process and transform our data. For that, we will use astype() function to change datatype of some columns to category.

Step 3: Now we will apply codes on some columns to convert their text values to numerical values. After applying codes, the dataset will look like this:

Category conversion for machine learning

Step 4: Now we divide the dataset as x and y. x contains all the input features and y is our output variable that is, Salary.

Step 5: We will split the dataset into train and test data which will be used to check the efficiency.

Step 6: Now we can train our model using training features (x_train, y_train) to build a Random Forest Regression Model.

Step 7: Once we have trained the model we will check the performance of our model using test data. After verifying the performance, our model is ready to deploy. We will save our model using pickle. The pickle module implements a fundamental, but powerful algorithm for serializing and de-serializing a Python object structure.


Build App using streamlit

Streamlit is an open-soource Python library that makes it easy to build beautiful custom web-apps for machine learning and data science.

We will write a streamlit code to create a GUI for taking input features which will predict the Salary of the candidate. After writing the code for app we will save the file as salary_app.py.

To run this web app, open anaconda prompt and type streamlit run salary_app.py. This will open a web page. Enter the required credentials and click on Predict My Salary button. The screenshot of the web app is listed below.

Machine learning predicted salary



Conclusion

This machine learning web app predicts the salary, by processing the various attributes of the candidate using Random Forest Regression algorithm.










Comments

Popular posts from this blog

STREAMLIT MULTIPAGE WEB APPLICATION | AREA CALCULATOR

Multipage Web App So far, we have worked with python streamlit library and we have built machine learning web applications using streamlit. In this blog we will see how to build a multi-page web app using streamlit. Streamlit multipage web app We can create multiple apps and navigate across each of them in a main app using a radio button. First, we have created separate apps for each shape to calculate the area of that particular shape example app1.py, app2.py, app3.py etc. Then we have created a main app and added a navigator using radio buttons. Now we just have to run the main app and navigate through the desired web page. Area Calculator This particular multipage web app we named it as area calculator. We have included introduction page and ten shapes of which we can calculate the area by putting required inputs. We have downloaded the multiapp.py framework from GitHub, as we have a greater number of web pages. Each shape in the navigation bar indicates new web p...