Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +39 -37
src/streamlit_app.py
CHANGED
|
@@ -1,40 +1,42 @@
|
|
| 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 |
+
# ←––– Point this at your deployed Flask API
|
| 6 |
+
BACKEND_URL = "https://Pushpak21-Pharmacy.hf.space/predict"
|
| 7 |
+
|
| 8 |
+
st.title("🎯 Pharmacy College Predictor")
|
| 9 |
+
st.write("Enter your details below:")
|
| 10 |
+
|
| 11 |
+
# Input controls
|
| 12 |
+
category = st.selectbox("Category", [
|
| 13 |
+
'GOPEN', 'GSC', 'GNTB', 'GOBC', 'GSEBC', 'LOPEN', 'LST', 'LOBC',
|
| 14 |
+
'EWS', 'GST', 'GNTC', 'LSC', 'LNTB', 'LNTD', 'LNTC', 'LSEBC',
|
| 15 |
+
'GNTA', 'GNTD', 'LNTA'
|
| 16 |
+
])
|
| 17 |
+
rank = st.number_input("Rank", min_value=1, value=1500)
|
| 18 |
+
percentage = st.number_input("Percentage", min_value=0.0, max_value=100.0, value=75.0)
|
| 19 |
+
|
| 20 |
+
if st.button("Predict Top 20 Choices"):
|
| 21 |
+
payload = {
|
| 22 |
+
"Category": category,
|
| 23 |
+
"Rank": rank,
|
| 24 |
+
"Percentage": percentage
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
# Call your backend API
|
| 28 |
+
resp = requests.post(BACKEND_URL, json=payload)
|
| 29 |
+
if resp.status_code != 200:
|
| 30 |
+
st.error(f"Backend error: {resp.status_code}")
|
| 31 |
+
st.write(resp.text)
|
| 32 |
+
else:
|
| 33 |
+
data = resp.json().get("top_20_predictions", [])
|
| 34 |
+
if not data:
|
| 35 |
+
st.warning("No predictions returned.")
|
| 36 |
+
else:
|
| 37 |
+
df = pd.DataFrame(data)
|
| 38 |
+
df.index = df.index + 1
|
| 39 |
+
df.reset_index(inplace=True)
|
| 40 |
+
df.rename(columns={"index": "Prediction Rank"}, inplace=True)
|
| 41 |
+
st.write("### Top‑20 Predicted Choices")
|
| 42 |
+
st.dataframe(df)
|