Spaces:
Sleeping
Sleeping
| # ruff: noqa: F403, F405 | |
| import streamlit as st | |
| import pandas as pd | |
| from chronos_conference.domain.inference import get_forecast | |
| from chronos_conference.adapters.filter_ts import filter_ts, get_properties | |
| from chronos_conference.adapters.model_instance import ChronosForecaster | |
| from chronos_conference.adapters.ts_plot import get_plot | |
| from chronos_conference.settings import * | |
| st.title("AWS Community Day Ecuador 2025") | |
| st.header( | |
| "Conferencia: Aprendiendo el Lenguaje de las series de tiempo con AWS Chronos Bolt" | |
| ) | |
| st.subheader("Ponente: Sebastian Sarasti") | |
| st.write( | |
| """ | |
| Esta aplicación demuestra cómo utilizar AWS Chronos Bolt para la predicción del clima mediante | |
| datos abiertos obtenidos del INAMHI. | |
| """ | |
| ) | |
| df = pd.read_parquet(PATH_DATA) | |
| col1, col2 = st.columns(2) | |
| with col1: | |
| min_date = st.date_input("Fecha mínima", value=MIN_PRED_DATE) | |
| with col2: | |
| max_date = st.date_input("Fecha máxima", value=MAX_PRED_DATE) | |
| city_choice = st.selectbox( | |
| "Seleccione la zona de la ciudad a predecir", ZONES_TO_PREDICT | |
| ) | |
| if not city_choice: | |
| st.stop() | |
| available_properties = get_properties(df, ZONE_COL, city_choice) | |
| if not available_properties: | |
| st.stop() | |
| col1, col2 = st.columns(2) | |
| with col1: | |
| property_choice = st.pills( | |
| "Seleccione la propiedad a predecir", | |
| available_properties, | |
| selection_mode="multi", | |
| ) | |
| with col2: | |
| n_steps = st.number_input( | |
| "Número de pasos a predecir", | |
| min_value=MIN_PRED_DATE_LIMIT, | |
| max_value=MAX_PRED_DATE_LIMIT, | |
| value=N_PRED_STEPS, | |
| ) | |
| if not property_choice: | |
| st.stop() | |
| execution_button = st.button("Ejecutar modelo") | |
| if not execution_button: | |
| st.stop() | |
| with st.spinner("Filtrando datos..."): | |
| df_useful = filter_ts( | |
| df, | |
| date_col=HISTORICAL_DATE_COLUMN, | |
| min_date=str(min_date), | |
| max_date=str(max_date), | |
| city_col=ZONE_COL, | |
| city_choice=city_choice, | |
| property_col=HISTORICAL_ITEM_COLUMN, | |
| property_choice=property_choice, | |
| ) | |
| model = ChronosForecaster(freq=FREQUENCY) | |
| with st.spinner("Modelo en ejecución..."): | |
| results = get_forecast( | |
| df=df_useful, | |
| date_col=HISTORICAL_DATE_COLUMN, | |
| target_col=HISTORICAL_TARGET_COLUMN, | |
| item_col=HISTORICAL_ITEM_COLUMN, | |
| model_instance=model, | |
| ) | |
| st.success("¡Ejecución completada!") | |
| st.write("Resultados de la ejecución:") | |
| fig = get_plot(df_useful, results) | |
| st.plotly_chart(fig, use_container_width=True) | |