RaidedCluster commited on
Commit
682b5ba
·
verified ·
1 Parent(s): bec26b0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +77 -0
app.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from catboost import CatBoostRegressor
4
+
5
+ # Load the saved CatBoost model.
6
+ model = CatBoostRegressor()
7
+ model.load_model("PlaceMe_CatBoost.cbm", format="cbm")
8
+
9
+ st.title("Salary Prediction App")
10
+
11
+ # Input fields
12
+ gender = st.selectbox("Gender", ["m", "f"])
13
+ perc_10 = st.number_input("10th Percentage", min_value=0.0, max_value=100.0, value=80.0)
14
+ perc_12 = st.number_input("12th Percentage", min_value=0.0, max_value=100.0, value=80.0)
15
+
16
+ # Tier: only 1 and 2 accepted.
17
+ tier = st.selectbox("College Tier", [1, 2])
18
+
19
+ # Specialization: restricted choices.
20
+ specializations = [
21
+ 'electronics & instrumentation',
22
+ 'computer science',
23
+ 'electronics & communication',
24
+ 'biotechnology',
25
+ 'mechanical',
26
+ 'information technology',
27
+ 'electrical engineering',
28
+ 'electronics and electrical engineering',
29
+ 'information science engineering',
30
+ 'chemical engineering',
31
+ 'ceramic engineering',
32
+ 'metallurgical engineering',
33
+ 'aeronautical engineering',
34
+ 'electronics engineering',
35
+ 'civil engineering',
36
+ 'industrial & production engineering',
37
+ 'other',
38
+ 'electronics and computer engineering',
39
+ 'industrial & management engineering',
40
+ 'biomedical engineering',
41
+ 'computer application',
42
+ 'electrical and power engineering',
43
+ 'industrial engineering',
44
+ 'mechatronics',
45
+ 'information & communication technology'
46
+ ]
47
+ specialization = st.selectbox("Specialization", specializations)
48
+
49
+ # CGPA: user inputs on 0-10 scale, then scale up to 100.
50
+ cgpa_input = st.number_input("College GPA (0-10 scale)", min_value=0.0, max_value=10.0, value=7.5)
51
+ college_gpa = cgpa_input * 10
52
+
53
+ # Location: accepted values.
54
+ locations = [
55
+ "Delhi", "Uttar Pradesh", "Maharashtra", "Tamil Nadu", "West Bengal", "Telangana",
56
+ "Andhra Pradesh", "Haryana", "Karnataka", "Orissa", "Chhattisgarh", "Rajasthan",
57
+ "Punjab", "Madhya Pradesh", "Uttarakhand", "Gujarat", "Jharkhand", "Himachal Pradesh",
58
+ "Bihar", "Kerala", "Assam", "Jammu and Kashmir", "Sikkim", "Meghalaya", "Goa"
59
+ ]
60
+ location = st.selectbox("Location", locations)
61
+
62
+ # Build the input DataFrame with columns expected by the model.
63
+ input_df = pd.DataFrame({
64
+ "Gender": [gender],
65
+ "10percentage": [perc_10],
66
+ "12percentage": [perc_12],
67
+ "CollegeTier": [tier],
68
+ "Specialization": [specialization],
69
+ "collegeGPA": [college_gpa],
70
+ "CollegeState": [location] # mapping 'Location' to model's 'CollegeState'
71
+ })
72
+
73
+ if st.button("Predict Salary"):
74
+ prediction = model.predict(input_df)
75
+ st.success(f"Predicted Salary: {prediction[0]:.2f}")
76
+
77
+ # To run, save this file (e.g., app.py) and execute 'streamlit run app.py'