Upload 2 files
Browse files- app.py +63 -0
- salPridict.pkl +3 -0
app.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from sklearn.pipeline import Pipeline
|
| 4 |
+
from sklearn.preprocessing import OrdinalEncoder, OneHotEncoder
|
| 5 |
+
from sklearn.compose import ColumnTransformer
|
| 6 |
+
from sklearn.ensemble import GradientBoostingRegressor
|
| 7 |
+
import pickle
|
| 8 |
+
|
| 9 |
+
with open('salPridict.pkl', 'rb') as file:
|
| 10 |
+
model = pickle.load(file)
|
| 11 |
+
|
| 12 |
+
# Function to preprocess input data
|
| 13 |
+
def preprocess_input(df):
|
| 14 |
+
# Preprocess input data here (e.g., encoding categorical variables, transforming date features)
|
| 15 |
+
# Convert 'DOJ' and 'CURRENT DATE' to datetime
|
| 16 |
+
df['DOJ'] = pd.to_datetime(df['DOJ'])
|
| 17 |
+
df['CURRENT DATE'] = pd.to_datetime('2016-07-01')
|
| 18 |
+
|
| 19 |
+
# Calculate tenure in days, then convert to years
|
| 20 |
+
df['TENURE'] = (df['CURRENT DATE'] - df['DOJ']).dt.days // 365.25
|
| 21 |
+
df['TOTAL_EXP'] = df['PAST_EXP'] + df['TENURE']
|
| 22 |
+
df = df.drop(columns=['DOJ', 'CURRENT DATE', 'NAME', 'PAST_EXP', 'TENURE', 'AGE'])
|
| 23 |
+
return df
|
| 24 |
+
# Function to make prediction
|
| 25 |
+
def predict_salary(data):
|
| 26 |
+
preprocessed_data = preprocess_input(data)
|
| 27 |
+
salary = model.predict(preprocessed_data)
|
| 28 |
+
return int(salary)
|
| 29 |
+
|
| 30 |
+
# Streamlit app
|
| 31 |
+
def main():
|
| 32 |
+
st.title('Salary Prediction App')
|
| 33 |
+
|
| 34 |
+
# Input fields
|
| 35 |
+
name = st.text_input('Name')
|
| 36 |
+
age = st.number_input('Age', min_value=0)
|
| 37 |
+
gender = st.selectbox('Gender', ['M', 'F'])
|
| 38 |
+
designation = st.selectbox('Designation', ['Analyst', 'Associate', 'Senior Analyst', 'Manager', 'Senior Manager', 'Director'])
|
| 39 |
+
unit = st.selectbox('Unit', ['Finance', 'IT', 'Marketing' ,'Operations' ,'Web', 'Management'])
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
past_experience = st.number_input('Past Experience', min_value=0)
|
| 43 |
+
rating = st.number_input('Rating', min_value=0.0, max_value=5.0, step=0.1)
|
| 44 |
+
date_of_join = st.date_input('Date of Join')
|
| 45 |
+
|
| 46 |
+
# Predict button
|
| 47 |
+
if st.button('Predict Salary'):
|
| 48 |
+
input_data = pd.DataFrame({
|
| 49 |
+
'NAME': [name],
|
| 50 |
+
'AGE': [age],
|
| 51 |
+
'SEX': [gender],
|
| 52 |
+
'DESIGNATION': [designation],
|
| 53 |
+
'UNIT': [unit],
|
| 54 |
+
'PAST_EXP': [past_experience],
|
| 55 |
+
'RATINGS': [rating],
|
| 56 |
+
'DOJ': [date_of_join]
|
| 57 |
+
})
|
| 58 |
+
salary_prediction = predict_salary(input_data)
|
| 59 |
+
st.success(f'Predicted Salary: {salary_prediction}')
|
| 60 |
+
|
| 61 |
+
if __name__ == '__main__':
|
| 62 |
+
main()
|
| 63 |
+
|
salPridict.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1fb9f2373d14d3b17e64597cccda52e5ea40e66a41f2bb86e088654fab0354b5
|
| 3 |
+
size 2454062
|