File size: 3,171 Bytes
43ffbab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9020b91
 
 
 
 
 
 
 
 
 
 
 
43ffbab
 
9020b91
 
43ffbab
9020b91
 
43ffbab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9020b91
 
 
091b01b
 
43ffbab
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import streamlit as st
import pandas as pd
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import OrdinalEncoder, OneHotEncoder
from sklearn.compose import ColumnTransformer
from sklearn.ensemble import GradientBoostingRegressor
import pickle

with open('salPridict.pkl', 'rb') as file:
  model = pickle.load(file)

# Function to preprocess input data
def preprocess_input(df):
    # Preprocess input data here (e.g., encoding categorical variables, transforming date features)
    # Convert 'DOJ' and 'CURRENT DATE' to datetime
    df['DOJ'] = pd.to_datetime(df['DOJ'])
    df['CURRENT DATE'] = pd.to_datetime('2016-07-01')

    # Calculate tenure in days, then convert to years
    df['TENURE'] = (df['CURRENT DATE'] - df['DOJ']).dt.days // 365.25
    df['TOTAL_EXP'] = df['PAST_EXP'] + df['TENURE']
    df = df.drop(columns=['DOJ', 'CURRENT DATE', 'NAME', 'PAST_EXP', 'TENURE', 'AGE'])
    total_experience=int(df['TOTAL_EXP'][0]) 
    # Provide salary increase recommendations based on total experience and rating
    if total_experience >= 5 :
        recommendation = "Your performance and experience suggest that you're well-positioned for a salary increase. Consider discussing this with your manager during your next performance review."
    elif total_experience >= 3 :
        recommendation = "You've gained valuable experience and have a solid performance rating. It might be a good time to explore opportunities for advancement within the company or discuss a salary review with your manager."
    else:
        recommendation = "Focus on enhancing your skills, gaining more experience, and improving your performance to increase your chances of a salary raise in the future."

    return df,recommendation


# Function to make prediction
def predict_salary(data):
    preprocessed_data,rec = preprocess_input(data)

    salary = model.predict(preprocessed_data)
    return salary,rec


# Streamlit app
def main():
    st.title('Salary Prediction App')

    # Input fields
    name = st.text_input('Name')
    age = st.number_input('Age', min_value=0)
    gender = st.selectbox('Gender', ['M', 'F'])
    designation = st.selectbox('Designation', ['Analyst', 'Associate', 'Senior Analyst', 'Manager', 'Senior Manager', 'Director'])
    unit = st.selectbox('Unit', ['Finance', 'IT', 'Marketing' ,'Operations' ,'Web', 'Management'])


    past_experience = st.number_input('Past Experience', min_value=0)
    rating = st.number_input('Rating', min_value=0.0, max_value=5.0, step=0.1)
    date_of_join = st.date_input('Date of Join')

    # Predict button
    if st.button('Predict Salary'):
        input_data = pd.DataFrame({
            'NAME': [name],
            'AGE': [age],
            'SEX': [gender],
            'DESIGNATION': [designation],
            'UNIT': [unit],
            'PAST_EXP': [past_experience],
            'RATINGS': [rating],
            'DOJ': [date_of_join]
        })
        
        salary_prediction,rec = predict_salary(input_data)

        st.success(f'Predicted Salary: {int(salary_prediction[0])}')
        st.success(f'One Recommendation for you {name}: {rec}')

if __name__ == '__main__':
    main()