pruebas_anibal / app.py
JairoDanielMT's picture
Create app.py
53e09be verified
raw
history blame
4.14 kB
import streamlit as st
import requests
import json
# T铆tulo de la aplicaci贸n
st.title("Predicci贸n de C谩ncer Cervical")
# Crear los campos de entrada para el formulario
behavior_sexualRisk = st.number_input("Risk Behavior (Sexual)", min_value=0.0, max_value=100.0, value=10.0)
behavior_eating = st.number_input("Eating Behavior", min_value=0.0, max_value=100.0, value=10.0)
behavior_personalHygine = st.number_input("Personal Hygiene", min_value=0.0, max_value=100.0, value=10.0)
intention_aggregation = st.number_input("Intention Aggregation", min_value=0.0, max_value=100.0, value=10.0)
intention_commitment = st.number_input("Intention Commitment", min_value=0.0, max_value=100.0, value=10.0)
attitude_consistency = st.number_input("Attitude Consistency", min_value=0.0, max_value=100.0, value=10.0)
attitude_spontaneity = st.number_input("Attitude Spontaneity", min_value=0.0, max_value=100.0, value=0.0)
norm_significantPerson = st.number_input("Norm Significant Person", min_value=0.0, max_value=100.0, value=0.0)
norm_fulfillment = st.number_input("Norm Fulfillment", min_value=0.0, max_value=100.0, value=0.0)
perception_vulnerability = st.number_input("Perception Vulnerability", min_value=0.0, max_value=100.0, value=0.0)
perception_severity = st.number_input("Perception Severity", min_value=0.0, max_value=100.0, value=0.0)
motivation_strength = st.number_input("Motivation Strength", min_value=0.0, max_value=100.0, value=0.34)
motivation_willingness = st.number_input("Motivation Willingness", min_value=0.0, max_value=100.0, value=0.54)
socialSupport_emotionality = st.number_input("Social Support Emotionality", min_value=0.0, max_value=100.0, value=0.0)
socialSupport_appreciation = st.number_input("Social Support Appreciation", min_value=0.0, max_value=100.0, value=0.0)
socialSupport_instrumental = st.number_input("Social Support Instrumental", min_value=0.0, max_value=100.0, value=0.0)
empowerment_knowledge = st.number_input("Empowerment Knowledge", min_value=0.0, max_value=100.0, value=10.0)
empowerment_abilities = st.number_input("Empowerment Abilities", min_value=0.0, max_value=100.0, value=20.0)
empowerment_desires = st.number_input("Empowerment Desires", min_value=0.0, max_value=100.0, value=0.0)
# Bot贸n para hacer la predicci贸n
if st.button("Obtener Diagn贸stico"):
# Crear el payload para la solicitud
payload = {
"behavior_sexualRisk": behavior_sexualRisk,
"behavior_eating": behavior_eating,
"behavior_personalHygine": behavior_personalHygine,
"intention_aggregation": intention_aggregation,
"intention_commitment": intention_commitment,
"attitude_consistency": attitude_consistency,
"attitude_spontaneity": attitude_spontaneity,
"norm_significantPerson": norm_significantPerson,
"norm_fulfillment": norm_fulfillment,
"perception_vulnerability": perception_vulnerability,
"perception_severity": perception_severity,
"motivation_strength": motivation_strength,
"motivation_willingness": motivation_willingness,
"socialSupport_emotionality": socialSupport_emotionality,
"socialSupport_appreciation": socialSupport_appreciation,
"socialSupport_instrumental": socialSupport_instrumental,
"empowerment_knowledge": empowerment_knowledge,
"empowerment_abilities": empowerment_abilities,
"empowerment_desires": empowerment_desires
}
# Hacer la solicitud a la API
url = 'https://jairodanielmt-ejemplo-anibal.hf.space/predict/'
headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
response = requests.post(url, json=payload, headers=headers)
# Verificar si la respuesta es exitosa
if response.status_code == 200:
# Mostrar el diagn贸stico recibido
result = response.json()
ca_cervix_prediction = result.get('ca_cervix_prediction', 'No disponible')
st.write(f"Diagn贸stico: {ca_cervix_prediction}")
else:
# Si ocurre un error en la solicitud
st.error("Ocurri贸 un error al obtener el diagn贸stico. Intenta nuevamente m谩s tarde.")