Commit
·
5a3b63d
1
Parent(s):
1c35603
Guardar mis cambios locales
Browse files
app.py
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
import pandas as pd
|
2 |
import matplotlib.pyplot as plt
|
3 |
-
import
|
4 |
import gradio as gr
|
5 |
|
6 |
def load_model():
|
7 |
try:
|
8 |
-
|
9 |
-
|
10 |
-
return arima_model, None
|
11 |
except Exception as e:
|
12 |
return None, f"Failed to load model: {str(e)}"
|
13 |
|
@@ -37,7 +36,6 @@ def forecast_sales(uploaded_file, forecast_period=30):
|
|
37 |
return f"Failed during forecasting: {str(e)}", None
|
38 |
|
39 |
try:
|
40 |
-
# Create the plot
|
41 |
fig, ax = plt.subplots(figsize=(10, 6))
|
42 |
ax.plot(df['ds'], df['y'], label='Historical Sales', color='blue')
|
43 |
ax.plot(forecast_df['Date'], forecast_df['Sales Forecast'], label='Sales Forecast', color='red', linestyle='--')
|
@@ -56,11 +54,9 @@ def setup_interface():
|
|
56 |
forecast_button = gr.Button("Forecast Sales")
|
57 |
output_text = gr.Textbox(visible=True)
|
58 |
output_plot = gr.Plot()
|
59 |
-
# Actualización aquí: Cambia 'default' por 'value'
|
60 |
-
forecast_period_slider = gr.Slider(1, 60, step=1, label="Forecast Period (days)", value=30)
|
61 |
forecast_button.click(
|
62 |
forecast_sales,
|
63 |
-
inputs=[file_input,
|
64 |
outputs=[output_text, output_plot]
|
65 |
)
|
66 |
return demo
|
|
|
1 |
import pandas as pd
|
2 |
import matplotlib.pyplot as plt
|
3 |
+
import joblib
|
4 |
import gradio as gr
|
5 |
|
6 |
def load_model():
|
7 |
try:
|
8 |
+
model = joblib.load('arima_sales_model.pkl')
|
9 |
+
return model, None
|
|
|
10 |
except Exception as e:
|
11 |
return None, f"Failed to load model: {str(e)}"
|
12 |
|
|
|
36 |
return f"Failed during forecasting: {str(e)}", None
|
37 |
|
38 |
try:
|
|
|
39 |
fig, ax = plt.subplots(figsize=(10, 6))
|
40 |
ax.plot(df['ds'], df['y'], label='Historical Sales', color='blue')
|
41 |
ax.plot(forecast_df['Date'], forecast_df['Sales Forecast'], label='Sales Forecast', color='red', linestyle='--')
|
|
|
54 |
forecast_button = gr.Button("Forecast Sales")
|
55 |
output_text = gr.Textbox(visible=True)
|
56 |
output_plot = gr.Plot()
|
|
|
|
|
57 |
forecast_button.click(
|
58 |
forecast_sales,
|
59 |
+
inputs=[file_input, gr.Slider(1, 60, step=1, label="Forecast Period (days)", value=30)],
|
60 |
outputs=[output_text, output_plot]
|
61 |
)
|
62 |
return demo
|