Summary
Hello everybody, in the app im developoing im importing an XGBoost model to make a prediction show the results in the app, but when i try to run it the app freezes and the connection is lost. I donāt know how to solve this issue.
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.graph_objs as go
import pickle
import streamlit as st
@st.cache_resource
def load_tea():
return pickle.load(open(ātea_LIC02.pklā, ārbā))
modelo_tea = load_tea()
descripcion = st.container()
inputs = st.container()
resultados = st.container()
st.sidebar.title(āDefinicionesā)
with st.sidebar:
st.markdown(āThe metrics shown in this dashboard and the defitions below, come from the standard ANSI/ISA 18.2 - 2016.ā)
st.markdown(āCO2 equivalente (CO2e): Medida utilizada para cuantificar el efecto de calentamiento global de cada uno de los gases de efecto invernaderoā)
st.markdown(āGases de efecto invernadero contabilizados: En esta herramienta se contabiliza la emisiĆ³n de los siguientes gases de efecto invernadero por combustiĆ³n de gas a tea: CO2, CO, NOx y SO2ā)
st.markdown(āNota: Para este caso las emisiones totalizadas se hacen con base en los valroes de emisiĆ³n del Ćŗltimo trimestre medidas en la planta.ā)
with descripcion:
col1, col2, col3 = st.columns([1,1,1])
with col2:
st.write('A continuaciĆ³n introduzca las condiciones de flujo, presiĆ³n, temperatura y composiciĆ³n del gas a analizar')
with inputs:
col1, col2, col3, col4, col5 = st.columns([1.2,1,1, 1, 1.2])
with col2:
flujo_tea = st.number_input(āFlujo a tea (MMSCFD)ā)
presiĆ³n = st.number_input(āPresiĆ³n gas (PSI)ā)
temperatura = st.number_input(āTemperatura gas (Ā°F)ā)
with col3:
comp_c1 = st.number_input('ComposiciĆ³n molar C1 (%)')
comp_c2 = st.number_input('ComposiciĆ³n molar C2 (%)')
comp_c3 = st.number_input('ComposiciĆ³n molar C3 (%)')
with col4:
comp_c4 = st.number_input('ComposiciĆ³n molar C4 (%)')
comp_c5 = st.number_input('ComposiciĆ³n molar C5 (%)')
comp_n2 = st.number_input('ComposiciĆ³n molar N2 (%)')
with resultados:
flujo_tea = flujo_tea*1000000
data =pd.DataFrame([[flujo_tea, comp_c1, comp_c2, comp_c3, comp_c4, comp_c5, comp_n2]], columns=['Flujo (ft3/d)', 'C1', 'C2',
'C3', 'C4', 'C5', 'N2'])
prediccion = modelo_tea.predict(data)
st.table(prediccion)
The problem comes in the last part, where im trying to make the predicction the app freezes it says connecting and then the app disconnects.
Im using the latest version of streamlit and the XGBoost model weighs 340 kb