Spaces:
Build error
Build error
Commit Β·
d6a9d49
1
Parent(s): c2dd111
update
Browse files- app.py +18 -15
- random_forest_ph_model.pkl +3 -0
- random_forest_tds_model.pkl +3 -0
- requirements.txt +4 -2
app.py
CHANGED
|
@@ -2,9 +2,9 @@ import streamlit as st
|
|
| 2 |
import requests
|
| 3 |
import pandas as pd
|
| 4 |
|
| 5 |
-
# Backend API URL
|
| 6 |
BACKEND_API_URL = "https://your-username-tds-ph-backend.hf.space/predict"
|
| 7 |
|
|
|
|
| 8 |
# Set up the main title and subtitle
|
| 9 |
st.title("π TDS and pH Level Predictor")
|
| 10 |
st.markdown("Get predictions for hourly **pH** and **TDS** levels based on selected date. Perfect for water quality monitoring!")
|
|
@@ -20,20 +20,23 @@ with st.sidebar.expander("π§ Input Parameters"):
|
|
| 20 |
col1, col2 = st.columns([1, 3])
|
| 21 |
with col1:
|
| 22 |
if st.button("π Predict"):
|
| 23 |
-
# Send request to backend API
|
| 24 |
response = requests.post(BACKEND_API_URL, json={"day": day, "month": month, "year": year})
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
with col2:
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
st.markdown("### π Prediction Results")
|
| 34 |
-
st.dataframe(results_df.style.set_properties(**{
|
| 35 |
-
'background-color': 'lavender',
|
| 36 |
-
'font-size': '14px'
|
| 37 |
-
}).highlight_max(axis=0, color='lightblue'))
|
| 38 |
-
else:
|
| 39 |
-
st.error("Error: Could not retrieve predictions. Please check the backend service.")
|
|
|
|
| 2 |
import requests
|
| 3 |
import pandas as pd
|
| 4 |
|
|
|
|
| 5 |
BACKEND_API_URL = "https://your-username-tds-ph-backend.hf.space/predict"
|
| 6 |
|
| 7 |
+
|
| 8 |
# Set up the main title and subtitle
|
| 9 |
st.title("π TDS and pH Level Predictor")
|
| 10 |
st.markdown("Get predictions for hourly **pH** and **TDS** levels based on selected date. Perfect for water quality monitoring!")
|
|
|
|
| 20 |
col1, col2 = st.columns([1, 3])
|
| 21 |
with col1:
|
| 22 |
if st.button("π Predict"):
|
|
|
|
| 23 |
response = requests.post(BACKEND_API_URL, json={"day": day, "month": month, "year": year})
|
| 24 |
|
| 25 |
+
|
| 26 |
+
# Refined DataFrame for predictions
|
| 27 |
+
if response.status_code == 200:
|
| 28 |
+
# Process and display the results
|
| 29 |
+
results = response.json()
|
| 30 |
+
results_df = pd.DataFrame(results)
|
| 31 |
+
st.write("### Predictions")
|
| 32 |
+
st.dataframe(results_df)
|
| 33 |
+
else:
|
| 34 |
+
st.error("Error: Could not retrieve predictions. Please check the backend service.")
|
| 35 |
+
|
| 36 |
+
# Display predictions with a header and a styled table
|
| 37 |
with col2:
|
| 38 |
+
st.markdown("### π Prediction Results")
|
| 39 |
+
st.dataframe(results_df.style.set_properties(**{
|
| 40 |
+
'background-color': 'lavender',
|
| 41 |
+
'font-size': '14px'
|
| 42 |
+
}).highlight_max(axis=0, color='lightblue'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
random_forest_ph_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2c2c5ad14396bf5e42f7cb858ce0df6d0ffb55b1218e06273a239e806e0647ae
|
| 3 |
+
size 593665
|
random_forest_tds_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:706e77a4f82f6a3fb65af960dbf10009f1cfedfb4249e2d34037ddcf3792f039
|
| 3 |
+
size 942593
|
requirements.txt
CHANGED
|
@@ -1,3 +1,5 @@
|
|
| 1 |
streamlit
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
| 1 |
streamlit
|
| 2 |
+
joblib
|
| 3 |
+
numpy==1.26.4
|
| 4 |
+
scikit-learn==1.2.2
|
| 5 |
+
pandas
|