Update src/streamlit_app.py
Browse files- src/streamlit_app.py +95 -37
src/streamlit_app.py
CHANGED
|
@@ -1,40 +1,98 @@
|
|
| 1 |
-
import
|
| 2 |
-
import numpy as np
|
| 3 |
import pandas as pd
|
| 4 |
import streamlit as st
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
import streamlit as st
|
| 4 |
|
| 5 |
+
# 🚀 Your deployed Flask backend URL
|
| 6 |
+
BACKEND_URL = "https://Pushpak21-EngineeringGeneral.hf.space/predict"
|
| 7 |
+
|
| 8 |
+
st.title("🎯 Engineering College Predictor")
|
| 9 |
+
st.write("Enter your details below:")
|
| 10 |
+
|
| 11 |
+
# 📋 Input controls
|
| 12 |
+
category = st.selectbox("Category", ['GOPEN', 'GSC', 'GSEBC', 'LOPEN', 'LST', 'LOBC', 'EWS', 'GST',
|
| 13 |
+
'GOBC', 'LSEBC', 'LSC', 'GNTA', 'LNTB', 'GNTB', 'GNTC', 'LNTA',
|
| 14 |
+
'GNTD', 'LNTC', 'LNTD', 'ORP'])
|
| 15 |
+
|
| 16 |
+
course = st.selectbox("Category", ['Civil Engineering', 'Computer Science and Engineering',
|
| 17 |
+
'Information Technology', 'Electrical Engineering',
|
| 18 |
+
'Electronics and Telecommunication Engg',
|
| 19 |
+
'Instrumentation Engineering', 'Mechanical Engineering',
|
| 20 |
+
'Computer Engineering', 'Electrical Engg[Electronics and Power]',
|
| 21 |
+
'Artificial Intelligence (AI) and Data Science', 'Industrial IoT',
|
| 22 |
+
'Artificial Intelligence and Data Science', 'Chemical Engineering',
|
| 23 |
+
'Computer Science and Engineering(Data Science)',
|
| 24 |
+
'Production Engineering', 'Textile Technology',
|
| 25 |
+
'Electronics and Computer Engineering',
|
| 26 |
+
'Computer Science and Engineering(Artificial Intelligence and Machine Learning)',
|
| 27 |
+
'Agricultural Engineering', 'Computer Science and Design',
|
| 28 |
+
'Plastic and Polymer Engineering', 'Electronics Engineering',
|
| 29 |
+
'Electrical and Electronics Engineering',
|
| 30 |
+
'Artificial Intelligence and Machine Learning',
|
| 31 |
+
'Electronics Engineering ( VLSI Design and Technology)',
|
| 32 |
+
'Electronics and Communication(Advanced Communication Technology)',
|
| 33 |
+
'Artificial Intelligence', 'Production Engineering[Sandwich]',
|
| 34 |
+
'Electronics and Telecommunication Engg[Direct Second Year Second Shift]',
|
| 35 |
+
'Petro Chemical Engineering', 'Computer Science and Technology',
|
| 36 |
+
'Electronics and Communication Engineering', 'Data Science',
|
| 37 |
+
'Mechatronics Engineering', 'Civil and infrastructure Engineering',
|
| 38 |
+
'Bio Medical Engineering', 'Electronics and Computer Science',
|
| 39 |
+
'Computer Science and Engineering (Internet of Things and Cyber Security Including Block Chain Technology)',
|
| 40 |
+
'Cyber Security', 'Mechanical & Automation Engineering',
|
| 41 |
+
'Food Technology', 'Paper and Pulp Technology',
|
| 42 |
+
'Computer Technology', 'Aeronautical Engineering',
|
| 43 |
+
'Mining Engineering', 'Computer Science and Engineering (IoT)',
|
| 44 |
+
'Oil Fats and Waxes Technology', 'Paints Technology',
|
| 45 |
+
'Instrumentation and Control Engineering',
|
| 46 |
+
'Automation and Robotics', 'Robotics and Automation',
|
| 47 |
+
'Structural Engineering', 'Civil and Environmental Engineering',
|
| 48 |
+
'Automobile Engineering', 'Robotics and Artificial Intelligence',
|
| 49 |
+
'Manufacturing Science and Engineering',
|
| 50 |
+
'Metallurgy and Material Technology',
|
| 51 |
+
'Computer Science and Business Systems',
|
| 52 |
+
'Computer Engineering (Software Engineering)',
|
| 53 |
+
'Computer Engineering[Direct Second Year Second Shift]',
|
| 54 |
+
'Computer Science and Information Technology',
|
| 55 |
+
'Fashion Technology', 'Textile Plant Engineering',
|
| 56 |
+
'Computer Science and Engineering (Artificial Intelligence and Data Science)',
|
| 57 |
+
'Electrical and Computer Engineering', 'Printing Technology',
|
| 58 |
+
'Mechanical Engineering[Sandwich]',
|
| 59 |
+
'Computer Science and Engineering (Artificial Intelligence)'])
|
| 60 |
+
|
| 61 |
+
rank = st.number_input("Rank", min_value=1, value=1500)
|
| 62 |
+
percentage = st.number_input("Percentage", min_value=0.0, max_value=100.0, value=75.0)
|
| 63 |
+
|
| 64 |
+
if st.button("Predict Top 20 Choices"):
|
| 65 |
+
payload = {
|
| 66 |
+
"Category": category,
|
| 67 |
+
"Rank": rank,
|
| 68 |
+
"Percentage": percentage,
|
| 69 |
+
"Course Name": course
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
# 🔷 Call your backend API
|
| 73 |
+
resp = requests.post(BACKEND_URL, json=payload)
|
| 74 |
+
if resp.status_code != 200:
|
| 75 |
+
st.error(f"Backend error: {resp.status_code}")
|
| 76 |
+
st.write(resp.text)
|
| 77 |
+
else:
|
| 78 |
+
data = resp.json().get("top_20_predictions", [])
|
| 79 |
+
if not data:
|
| 80 |
+
st.warning("No predictions returned.")
|
| 81 |
+
else:
|
| 82 |
+
df = pd.DataFrame(data)
|
| 83 |
+
|
| 84 |
+
# Reorder & rename columns
|
| 85 |
+
df = df[["rank", "choice_code", "college_name", "probability_percent"]]
|
| 86 |
+
df.rename(columns={
|
| 87 |
+
"rank": "Rank",
|
| 88 |
+
"choice_code": "Choice Code",
|
| 89 |
+
"college_name": "College Name",
|
| 90 |
+
"probability_percent": "Probability (%)"
|
| 91 |
+
}, inplace=True)
|
| 92 |
+
|
| 93 |
+
# 🎯 Display table without index and full width
|
| 94 |
+
st.write("### 🎯 Top‑20 Predicted Choices")
|
| 95 |
+
st.dataframe(
|
| 96 |
+
df.style.hide(axis="index"),
|
| 97 |
+
use_container_width=True
|
| 98 |
+
)
|