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