Commit
·
7407a4e
1
Parent(s):
b672e36
Guardar mis cambios locales
Browse files
app.py
CHANGED
@@ -1,9 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
-
import numpy as np
|
4 |
-
import plotly.graph_objects as go
|
5 |
import joblib # Para cargar el modelo ARIMA guardado
|
6 |
-
from datetime import datetime
|
7 |
|
8 |
# Función para cargar el modelo ARIMA guardado
|
9 |
def load_arima_model():
|
@@ -36,12 +33,24 @@ def merge_forecast_data(actual, predicted, future):
|
|
36 |
"Forecasted Future Sales": future
|
37 |
})
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
# Función principal para la carga de archivo y la predicción
|
40 |
def upload_and_forecast(uploaded_file, period):
|
41 |
-
|
42 |
-
|
|
|
|
|
43 |
|
44 |
-
df = pd.read_csv(uploaded_file)
|
45 |
df = drop(df)
|
46 |
df = date_format(df)
|
47 |
series = group_to_three(df)
|
@@ -77,7 +86,7 @@ def upload_and_forecast(uploaded_file, period):
|
|
77 |
def create_sidebar():
|
78 |
with gr.Column():
|
79 |
gr.Markdown("### 📂 Upload your sales data (CSV)")
|
80 |
-
uploaded_file = gr.File(label="Choose your file", elem_id="file-uploader")
|
81 |
gr.Markdown("### ⏳ Forecast Period (Days)")
|
82 |
period = gr.Slider(minimum=30, maximum=90, step=1, label="Forecast period (in days)")
|
83 |
return uploaded_file, period
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
|
|
|
|
3 |
import joblib # Para cargar el modelo ARIMA guardado
|
|
|
4 |
|
5 |
# Función para cargar el modelo ARIMA guardado
|
6 |
def load_arima_model():
|
|
|
33 |
"Forecasted Future Sales": future
|
34 |
})
|
35 |
|
36 |
+
# Función para mostrar una alerta si el archivo no es CSV
|
37 |
+
def check_file(uploaded_file):
|
38 |
+
if uploaded_file is None:
|
39 |
+
return gr.Error("⚠️ No file uploaded. Please upload a CSV file.")
|
40 |
+
|
41 |
+
if uploaded_file.name.endswith('.csv'):
|
42 |
+
return None # Si el archivo es CSV, no hay error
|
43 |
+
else:
|
44 |
+
return gr.Error("⚠️ Invalid file format. Please upload a CSV file.") # Mostrar alerta si no es CSV
|
45 |
+
|
46 |
# Función principal para la carga de archivo y la predicción
|
47 |
def upload_and_forecast(uploaded_file, period):
|
48 |
+
# Verificar si el archivo cargado es CSV
|
49 |
+
error_message = check_file(uploaded_file)
|
50 |
+
if error_message:
|
51 |
+
return error_message
|
52 |
|
53 |
+
df = pd.read_csv(uploaded_file) # Leer el archivo CSV
|
54 |
df = drop(df)
|
55 |
df = date_format(df)
|
56 |
series = group_to_three(df)
|
|
|
86 |
def create_sidebar():
|
87 |
with gr.Column():
|
88 |
gr.Markdown("### 📂 Upload your sales data (CSV)")
|
89 |
+
uploaded_file = gr.File(label="Choose your file", elem_id="file-uploader", type="file")
|
90 |
gr.Markdown("### ⏳ Forecast Period (Days)")
|
91 |
period = gr.Slider(minimum=30, maximum=90, step=1, label="Forecast period (in days)")
|
92 |
return uploaded_file, period
|