| | import gradio as gr |
| | import numpy as np |
| | import joblib |
| |
|
| | |
| | model = joblib.load('titanic.pkl') |
| |
|
| | def predict_survival(sex, age, fare, pclass, sibsp): |
| | |
| | |
| | sex = 1 if sex == "Masculino" else 0 |
| | |
| | |
| | input_features = np.array([[sex, age, fare, pclass, sibsp]]) |
| | |
| | |
| | prediction = model.predict(input_features) |
| | |
| | |
| | result = 'Sobrevive' if prediction[0] == 1 else 'No sobrevive' |
| | return result |
| |
|
| | |
| | iface = gr.Interface( |
| | fn=predict_survival, |
| | inputs=[ |
| | gr.components.Dropdown(choices=["Masculino", "Femenino"], label="Sexo"), |
| | gr.components.Slider(minimum=0, maximum=100, step=1, value=28, label="Edad"), |
| | gr.components.Slider(minimum=0, maximum=512, step=1, value=33, label="Tarifa"), |
| | gr.components.Dropdown(choices=[1, 2, 3], label="Clase del Pasajero"), |
| | gr.components.Slider(minimum=0, maximum=8, step=1, value=0, label="Hermanos/C贸nyuges a bordo") |
| | ], |
| | outputs=gr.components.Textbox(label="Predicci贸n de Supervivencia") |
| | ) |
| |
|
| | |
| | iface.launch() |
| |
|