CoolFace
Apppublic

User-not-found11/logistic-regression

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
app.py24 linesDownload Raw Back to root
1import gradio as gr2import joblib3import numpy as np4 5model = joblib.load("logistic_model.joblib")6 7def predict(pclass, sex, age, sibsp, parch, fare, embarked):8    sex = 1 if sex == "male" else 09    embarked = {"C": 0, "Q": 1, "S": 2}.get(embarked, 2)10    input_data = np.array([[pclass, sex, age, sibsp, parch, fare, embarked]])11    prediction = model.predict(input_data)[0]12    return "Survived" if prediction == 1 else "Did Not Survive"13 14inputs = [15    gr.Slider(1, 3, step=1, label="Pclass"),16    gr.Radio(["male", "female"], label="Sex"),17    gr.Number(label="Age"),18    gr.Slider(0, 8, step=1, label="Siblings/Spouses (SibSp)"),19    gr.Slider(0, 6, step=1, label="Parents/Children (Parch)"),20    gr.Number(label="Fare"),21    gr.Radio(["C", "Q", "S"], label="Embarked")22]23 24gr.Interface(fn=predict, inputs=inputs, outputs="text", title="Titanic Survival Prediction – Logistic Regression").launch()