Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -51,6 +51,7 @@ def predict_values(start_doc, end_doc, days_option):
|
|
51 |
|
52 |
# Generate DOC values within the specified range
|
53 |
doc_values = np.linspace(start_doc, end_doc, num=len(farm_future_rate)) # Adjusted line
|
|
|
54 |
|
55 |
# Assign the generated DOC values to the future dataframes
|
56 |
farm_future_rate['DOC'] = doc_values
|
@@ -64,18 +65,13 @@ def predict_values(start_doc, end_doc, days_option):
|
|
64 |
|
65 |
# Filter to get only the future predictions (last `days_option` days)
|
66 |
farm_output = farm_forecast_rate[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail(days_option).copy()
|
67 |
-
farm_output['DOC'] = farm_future_rate['DOC'].tail(days_option)
|
68 |
|
69 |
open_output = open_forecast_rate[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail(days_option).copy()
|
70 |
-
open_output['DOC'] = open_future_rate['DOC'].tail(days_option)
|
71 |
|
72 |
close_output = close_forecast_rate[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail(days_option).copy()
|
73 |
-
close_output['DOC'] = close_future_rate['DOC'].tail(days_option)
|
74 |
-
|
75 |
-
# Round float values to two decimal places
|
76 |
-
farm_output[['yhat', 'yhat_lower', 'yhat_upper']] = farm_output[['yhat', 'yhat_lower', 'yhat_upper']].round(2)
|
77 |
-
open_output[['yhat', 'yhat_lower', 'yhat_upper']] = open_output[['yhat', 'yhat_lower', 'yhat_upper']].round(2)
|
78 |
-
close_output[['yhat', 'yhat_lower', 'yhat_upper']] = close_output[['yhat', 'yhat_lower', 'yhat_upper']].round(2)
|
79 |
|
80 |
# Create Plotly graphs
|
81 |
fig_farm = go.Figure()
|
@@ -98,7 +94,7 @@ def interface(start_doc, end_doc, days_option):
|
|
98 |
if days_option is None:
|
99 |
return "Please select a valid option for days.", None, None, None, None, None
|
100 |
|
101 |
-
days_map = {'7 days': 7, '10 days': 10, '15 days': 15,'40 days':40}
|
102 |
days_selected = days_map.get(days_option, 7) # Default to 7 days if no valid option is provided
|
103 |
results_farm, results_open, results_close, plot_farm, plot_open, plot_close = predict_values(start_doc, end_doc, days_selected)
|
104 |
return results_farm, results_open, results_close, plot_farm, plot_open, plot_close
|
@@ -106,7 +102,7 @@ def interface(start_doc, end_doc, days_option):
|
|
106 |
# Create Gradio inputs and outputs
|
107 |
start_doc_input = gr.components.Number(label="Start DOC Value")
|
108 |
end_doc_input = gr.components.Number(label="End DOC Value")
|
109 |
-
days_dropdown = gr.components.Dropdown(choices=['7 days', '10 days', '15 days','40 days'], label="Select Number of Days",value='7 days')
|
110 |
|
111 |
# Define output components
|
112 |
output_table_farm = gr.components.Dataframe(label="Predicted Farm Rate Values")
|
|
|
51 |
|
52 |
# Generate DOC values within the specified range
|
53 |
doc_values = np.linspace(start_doc, end_doc, num=len(farm_future_rate)) # Adjusted line
|
54 |
+
doc_values = np.round(doc_values, 1) # Round DOC values to 1 decimal place
|
55 |
|
56 |
# Assign the generated DOC values to the future dataframes
|
57 |
farm_future_rate['DOC'] = doc_values
|
|
|
65 |
|
66 |
# Filter to get only the future predictions (last `days_option` days)
|
67 |
farm_output = farm_forecast_rate[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail(days_option).copy()
|
68 |
+
farm_output['DOC'] = np.round(farm_future_rate['DOC'].tail(days_option), 1) # Round DOC values
|
69 |
|
70 |
open_output = open_forecast_rate[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail(days_option).copy()
|
71 |
+
open_output['DOC'] = np.round(open_future_rate['DOC'].tail(days_option), 1) # Round DOC values
|
72 |
|
73 |
close_output = close_forecast_rate[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail(days_option).copy()
|
74 |
+
close_output['DOC'] = np.round(close_future_rate['DOC'].tail(days_option), 1) # Round DOC values
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
# Create Plotly graphs
|
77 |
fig_farm = go.Figure()
|
|
|
94 |
if days_option is None:
|
95 |
return "Please select a valid option for days.", None, None, None, None, None
|
96 |
|
97 |
+
days_map = {'7 days': 7, '10 days': 10, '15 days': 15, '40 days': 40}
|
98 |
days_selected = days_map.get(days_option, 7) # Default to 7 days if no valid option is provided
|
99 |
results_farm, results_open, results_close, plot_farm, plot_open, plot_close = predict_values(start_doc, end_doc, days_selected)
|
100 |
return results_farm, results_open, results_close, plot_farm, plot_open, plot_close
|
|
|
102 |
# Create Gradio inputs and outputs
|
103 |
start_doc_input = gr.components.Number(label="Start DOC Value")
|
104 |
end_doc_input = gr.components.Number(label="End DOC Value")
|
105 |
+
days_dropdown = gr.components.Dropdown(choices=['7 days', '10 days', '15 days', '40 days'], label="Select Number of Days", value='7 days')
|
106 |
|
107 |
# Define output components
|
108 |
output_table_farm = gr.components.Dataframe(label="Predicted Farm Rate Values")
|