Pushpak21 commited on
Commit
134789a
·
verified ·
1 Parent(s): 6165ce7

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +95 -37
src/streamlit_app.py CHANGED
@@ -1,40 +1,98 @@
1
- import altair as alt
2
- import numpy as np
3
  import pandas as pd
4
  import streamlit as st
5
 
6
- """
7
- # Welcome to Streamlit!
8
-
9
- Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
10
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
11
- forums](https://discuss.streamlit.io).
12
-
13
- In the meantime, below is an example of what you can do with just a few lines of code:
14
- """
15
-
16
- num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
17
- num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
18
-
19
- indices = np.linspace(0, 1, num_points)
20
- theta = 2 * np.pi * num_turns * indices
21
- radius = indices
22
-
23
- x = radius * np.cos(theta)
24
- y = radius * np.sin(theta)
25
-
26
- df = pd.DataFrame({
27
- "x": x,
28
- "y": y,
29
- "idx": indices,
30
- "rand": np.random.randn(num_points),
31
- })
32
-
33
- st.altair_chart(alt.Chart(df, height=700, width=700)
34
- .mark_point(filled=True)
35
- .encode(
36
- x=alt.X("x", axis=None),
37
- y=alt.Y("y", axis=None),
38
- color=alt.Color("idx", legend=None, scale=alt.Scale()),
39
- size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
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
+ )