EngineeringGeneralFrontEnd / src /streamlit_app.py
Pushpak21's picture
Update src/streamlit_app.py
2cb0cdc verified
import requests
import pandas as pd
import streamlit as st
# πŸš€ Your deployed Flask backend URL
BACKEND_URL = "https://Pushpak21-EngineeringGeneral.hf.space/predict"
st.title("🎯 Engineering College Predictor")
st.write("Enter your details below:")
# πŸ“‹ Input controls
category = st.selectbox("Category", ['GOPEN', 'GSC', 'GSEBC', 'LOPEN', 'LST', 'LOBC', 'EWS', 'GST',
'GOBC', 'LSEBC', 'LSC', 'GNTA', 'LNTB', 'GNTB', 'GNTC', 'LNTA',
'GNTD', 'LNTC', 'LNTD', 'ORP'])
course_list = [
'Civil Engineering', 'Computer Science and Engineering',
'Information Technology', 'Electrical Engineering',
'Electronics and Telecommunication Engg',
'Instrumentation Engineering', 'Mechanical Engineering',
'Computer Engineering', 'Electrical Engg[Electronics and Power]',
'Artificial Intelligence (AI) and Data Science', 'Industrial IoT',
'Artificial Intelligence and Data Science', 'Chemical Engineering',
'Computer Science and Engineering(Data Science)',
'Production Engineering', 'Textile Technology',
'Electronics and Computer Engineering',
'Computer Science and Engineering(Artificial Intelligence and Machine Learning)',
'Agricultural Engineering', 'Computer Science and Design',
'Plastic and Polymer Engineering', 'Electronics Engineering',
'Electrical and Electronics Engineering',
'Artificial Intelligence and Machine Learning',
'Electronics Engineering ( VLSI Design and Technology)',
'Electronics and Communication(Advanced Communication Technology)',
'Artificial Intelligence', 'Production Engineering[Sandwich]',
'Electronics and Telecommunication Engg[Direct Second Year Second Shift]',
'Petro Chemical Engineering', 'Computer Science and Technology',
'Electronics and Communication Engineering', 'Data Science',
'Mechatronics Engineering', 'Civil and infrastructure Engineering',
'Bio Medical Engineering', 'Electronics and Computer Science',
'Computer Science and Engineering (Internet of Things and Cyber Security Including Block Chain Technology)',
'Cyber Security', 'Mechanical & Automation Engineering',
'Food Technology', 'Paper and Pulp Technology',
'Computer Technology', 'Aeronautical Engineering',
'Mining Engineering', 'Computer Science and Engineering (IoT)',
'Oil Fats and Waxes Technology', 'Paints Technology',
'Instrumentation and Control Engineering',
'Automation and Robotics', 'Robotics and Automation',
'Structural Engineering', 'Civil and Environmental Engineering',
'Automobile Engineering', 'Robotics and Artificial Intelligence',
'Manufacturing Science and Engineering',
'Metallurgy and Material Technology',
'Computer Science and Business Systems',
'Computer Engineering (Software Engineering)',
'Computer Engineering[Direct Second Year Second Shift]',
'Computer Science and Information Technology',
'Fashion Technology', 'Textile Plant Engineering',
'Computer Science and Engineering (Artificial Intelligence and Data Science)',
'Electrical and Computer Engineering', 'Printing Technology',
'Mechanical Engineering[Sandwich]',
'Computer Science and Engineering (Artificial Intelligence)'
]
# Sort alphabetically
course_list_sorted = sorted(course_list)
course = st.selectbox("Category", course_list_sorted)
rank = st.number_input("Rank", min_value=1, value=1500)
percentage = st.number_input("Percentage", min_value=0.0, max_value=100.0, value=75.0)
if st.button("Predict Top 20 Choices"):
payload = {
"Category": category,
"Rank": rank,
"Percentage": percentage,
"Course Name": course
}
# πŸ”· Call your backend API
resp = requests.post(BACKEND_URL, json=payload)
if resp.status_code != 200:
st.error(f"Backend error: {resp.status_code}")
st.write(resp.text)
else:
data = resp.json().get("top_20_predictions", [])
if not data:
st.warning("No predictions returned.")
else:
df = pd.DataFrame(data)
# Reorder & rename columns
df = df[["rank", "choice_code", "college_name", "probability_percent"]]
df.rename(columns={
"rank": "Rank",
"choice_code": "Choice Code",
"college_name": "College Name",
"probability_percent": "Probability (%)"
}, inplace=True)
# 🎯 Display table without index and full width
st.write("### 🎯 Top‑20 Predicted Choices")
st.dataframe(
df.style.hide(axis="index"),
use_container_width=True
)