Anders-sonderby commited on
Commit
56fb37f
·
verified ·
1 Parent(s): 73fbcc6

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +50 -0
  2. requirements.txt +19 -3
  3. salary_model.pkl +3 -0
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import joblib
4
+ import os
5
+
6
+ # --- Load the model ---
7
+ script_dir = os.path.dirname(__file__)
8
+ model_path = os.path.join(script_dir, "salary_model.pkl") # your saved model
9
+
10
+ st.title("💼 AI Salary Prediction App")
11
+ st.write("This tool predicts a developer's estimated salary based on their background and experience.")
12
+
13
+ try:
14
+ model_pipeline = joblib.load(model_path)
15
+ st.success("✅ Model loaded successfully!")
16
+ except Exception as e:
17
+ st.error(f"❌ Error loading the model: {e}")
18
+ st.stop()
19
+
20
+ # --- User input section ---
21
+ st.sidebar.header("Input your details")
22
+
23
+ age = st.sidebar.slider("Age", 18, 65, 30)
24
+ years_code_pro = st.sidebar.slider("Years of professional coding experience", 0, 40, 5)
25
+ country = st.sidebar.selectbox("Country", ["Denmark", "Germany", "Croatia", "Portugal", "Italy", "Netherlands"])
26
+ education = st.sidebar.selectbox("Education level", [
27
+ "Bachelor’s degree",
28
+ "Master’s degree (M.A., M.S., M.Eng., MBA, etc.)",
29
+ "Doctoral degree",
30
+ "Less than Bachelor’s"
31
+ ])
32
+ remote = st.sidebar.selectbox("Work arrangement", ["Remote", "Hybrid", "On-site"])
33
+
34
+ # --- Create a DataFrame for prediction ---
35
+ input_data = pd.DataFrame({
36
+ "age_group": [age],
37
+ "years_code_pro": [years_code_pro],
38
+ "country": [country],
39
+ "ed_level": [education],
40
+ "remote_work": [remote]
41
+ })
42
+
43
+ # --- Predict salary ---
44
+ if st.button("Predict Salary"):
45
+ try:
46
+ predicted_salary = model_pipeline.predict(input_data)[0]
47
+ st.subheader(f"💰 Predicted Salary: €{predicted_salary:,.0f}")
48
+ except Exception as e:
49
+ st.error(f"Error making prediction: {e}")
50
+
requirements.txt CHANGED
@@ -1,3 +1,19 @@
1
- altair
2
- pandas
3
- streamlit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Core libraries
2
+ numpy==2.0.2
3
+ pandas==2.3.2
4
+
5
+ # Visualization (optional, but useful)
6
+ matplotlib==3.9.4
7
+ seaborn==0.13.2
8
+
9
+ # Machine learning
10
+ scikit-learn==1.6.1
11
+ xgboost==2.1.4
12
+ optuna==4.5.0
13
+ joblib==1.5.2
14
+
15
+ # Model explainability
16
+ shap==0.48.0
17
+
18
+ # App framework
19
+ streamlit==1.49.1
salary_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0898200c76b7e2039f554bd30767ac7138e0a26dbe8bd5ee87b96c22fb70984f
3
+ size 20732851