Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added models/lasso_model (1).sav
Binary file not shown.
56 changes: 37 additions & 19 deletions streamlit_tutorial.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,47 @@
import streamlit as st
import joblib
model_path = 'models/lasso_model.sav'
from streamlit_extras.switch_page_button import switch_page
import random

def main():
st.title('Bienvenido al portal predictivo de la empresa XYZ')
st.write('**Por favor seleccione el servicio predictivo que desea utilizar**')
st.title('Bienvenido al portal de Seguros "Securitas"')
st.write('**Aquí se puede calcular el precio anual de prima que se pagará**')

opcion = st.radio('Seleccione el servicio:',
('Predicción del tipo de flor (con CSV)', 'Predicción del tipo de flor (manualmente)', 'Predicción de imagen','Maqueta','Sliders'),
index=0,
key='option')
# Añadir un selector de fecha
publish_date = st.date_input("Quotation Date")
# Diccionario para almacenar los datos de entrada
input_data = {}
# Widget de entrada numérica para cada característica
edad = st.number_input('Type your Age: ', min_value=0, max_value=99)
# Sexo
sexo = st.selectbox('Select your Gender: ',('Male','Female'))
# BMI
bmi = st.number_input('Insert you BMI:', format="%0.2f", value="min", min_value=15.0, max_value=50.00)
# Fumador
fumador = st.selectbox('Do you smoke?: ',('Yes','No'))
# Hijos
hijos = st.slider('Choose your number of children: ', min_value=0, max_value=9)
# Calcular precio cuando se pulsa el botón
if st.button("Calculate Price"):
precio = random.randint(1000, 1500)
st.write(f"el precio de tu seguro es: {precio} Euros")



if st.button('Empezar!'):
route_prediction(opcion)
def load_model(model_path):
try:
model = joblib.load(model_path) # cargar el modelo .sav
return model
except Exception as e:
st.error(f"Error loading model: {e}")
return None

def route_prediction(opcion):
if opcion == 'Predicción del tipo de flor (con CSV)':
switch_page("pred_iris_csv")
elif opcion == 'Predicción del tipo de flor (manualmente)':
switch_page("pred_iris_man")
elif opcion == 'Predicción de imagen':
switch_page("pred_imagen")
elif opcion == 'Maqueta':
switch_page("maqueta")
elif opcion == 'Sliders':
switch_page("sliders")
# with open(model_path, 'rb') as file:
# model = pickle.load(file)
# with st.spinner("Generando historia..."):
# response = get_text_response(text_model_pro, prompt, config)
# st.write(response)

if __name__ == "__main__":
main()
Expand Down