Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,12 +50,12 @@ with st.form(key="my_form"):
|
|
| 50 |
st.markdown("<h1 style='text-align: center; background-color: #f4edcd;color:black'>Crop Yield Prediction</h1>", unsafe_allow_html=True)
|
| 51 |
|
| 52 |
crop = st.selectbox("Choose a Crop:", options=cropOptions)
|
| 53 |
-
area = st.number_input("Area (in hectares):"
|
| 54 |
area_error = "" if re.match(r"^\d+(\.\d+)?$", area) or not area else "Invalid input for area. Enter a numeric value without commas or special characters."
|
| 55 |
if area_error:
|
| 56 |
st.markdown(f"<span style='color:red;'>{area_error}</span>", unsafe_allow_html=True)
|
| 57 |
|
| 58 |
-
production = st.number_input("Production (in metric tons):"
|
| 59 |
production_error = "" if re.match(r"^\d+(\.\d+)?$", production) or not production else "Invalid input for production. Enter a numeric value without commas or special characters."
|
| 60 |
if production_error:
|
| 61 |
st.markdown(f"<span style='color:red;'>{production_error}</span>", unsafe_allow_html=True)
|
|
@@ -64,7 +64,7 @@ with st.form(key="my_form"):
|
|
| 64 |
fertilizer = st.slider("Fertilizer (in kilograms).", min(df['Fertilizer']), max(df['Fertilizer']), value=min(df['Fertilizer']))
|
| 65 |
pesticide = st.slider("Pesticide (in kilograms).", min(df['Pesticide']), max(df['Pesticide']), value=min(df['Pesticide']))
|
| 66 |
|
| 67 |
-
|
| 68 |
|
| 69 |
# Handle Form Submission
|
| 70 |
if submit_button:
|
|
@@ -89,4 +89,4 @@ if submit_button:
|
|
| 89 |
unsafe_allow_html=True
|
| 90 |
)
|
| 91 |
except Exception as e:
|
| 92 |
-
st.error(f"Error in prediction: {e}")
|
|
|
|
| 50 |
st.markdown("<h1 style='text-align: center; background-color: #f4edcd;color:black'>Crop Yield Prediction</h1>", unsafe_allow_html=True)
|
| 51 |
|
| 52 |
crop = st.selectbox("Choose a Crop:", options=cropOptions)
|
| 53 |
+
area = st.number_input("Area (in hectares):")
|
| 54 |
area_error = "" if re.match(r"^\d+(\.\d+)?$", area) or not area else "Invalid input for area. Enter a numeric value without commas or special characters."
|
| 55 |
if area_error:
|
| 56 |
st.markdown(f"<span style='color:red;'>{area_error}</span>", unsafe_allow_html=True)
|
| 57 |
|
| 58 |
+
production = st.number_input("Production (in metric tons):")
|
| 59 |
production_error = "" if re.match(r"^\d+(\.\d+)?$", production) or not production else "Invalid input for production. Enter a numeric value without commas or special characters."
|
| 60 |
if production_error:
|
| 61 |
st.markdown(f"<span style='color:red;'>{production_error}</span>", unsafe_allow_html=True)
|
|
|
|
| 64 |
fertilizer = st.slider("Fertilizer (in kilograms).", min(df['Fertilizer']), max(df['Fertilizer']), value=min(df['Fertilizer']))
|
| 65 |
pesticide = st.slider("Pesticide (in kilograms).", min(df['Pesticide']), max(df['Pesticide']), value=min(df['Pesticide']))
|
| 66 |
|
| 67 |
+
submit_button = st.form_submit_button(label="Predict")
|
| 68 |
|
| 69 |
# Handle Form Submission
|
| 70 |
if submit_button:
|
|
|
|
| 89 |
unsafe_allow_html=True
|
| 90 |
)
|
| 91 |
except Exception as e:
|
| 92 |
+
st.error(f"Error in prediction: {e}")
|