Spaces:
Running
Running
Esmaeilkiani
commited on
Commit
•
bd637b6
1
Parent(s):
cefdbbd
Update app.py
Browse files
app.py
CHANGED
@@ -75,14 +75,25 @@ if st.button('نمایش نقشه NDRE'):
|
|
75 |
if st.button("Predict"):
|
76 |
# Retrieve NDRE value from session state, default to 0 if not set
|
77 |
ndre_value = st.session_state.get('ndre_value', 0)
|
|
|
|
|
78 |
user_input = pd.DataFrame({
|
79 |
-
'
|
80 |
-
'
|
81 |
-
'Farm_Variety': [farm_variety],
|
82 |
'NDRE': [ndre_value] # Use the retrieved NDRE value
|
83 |
-
})
|
84 |
-
|
85 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
prediction = model.predict(user_input)
|
87 |
|
88 |
st.write("Predictions:")
|
|
|
75 |
if st.button("Predict"):
|
76 |
# Retrieve NDRE value from session state, default to 0 if not set
|
77 |
ndre_value = st.session_state.get('ndre_value', 0)
|
78 |
+
|
79 |
+
# Prepare the user input DataFrame
|
80 |
user_input = pd.DataFrame({
|
81 |
+
'Age': [farm_age], # Rename to match model's expected feature
|
82 |
+
'Variety': [farm_variety], # Rename to match model's expected feature
|
|
|
83 |
'NDRE': [ndre_value] # Use the retrieved NDRE value
|
84 |
+
})
|
85 |
+
|
86 |
+
# Additional features: calculate DayOfYear and Month from the start date
|
87 |
+
if start_date:
|
88 |
+
day_of_year = start_date.timetuple().tm_yday
|
89 |
+
month = start_date.month
|
90 |
+
user_input['DayOfYear'] = [day_of_year]
|
91 |
+
user_input['Month'] = [month]
|
92 |
+
|
93 |
+
# Reorder the columns to match the order expected by the model
|
94 |
+
user_input = user_input[['Age', 'DayOfYear', 'Month', 'Variety', 'NDRE']]
|
95 |
+
|
96 |
+
# Make predictions
|
97 |
prediction = model.predict(user_input)
|
98 |
|
99 |
st.write("Predictions:")
|