Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,9 +8,6 @@ model = joblib.load('titanic_model.pkl')
|
|
| 8 |
# Fonction pour faire la prédiction
|
| 9 |
def predict(pclass, sex_male, age, siblings_spouses, parents_children, fare):
|
| 10 |
try:
|
| 11 |
-
print("Entrées reçues :")
|
| 12 |
-
print(f"Classe: {pclass}, Sexe: {sex_male}, Âge: {age}, Frères/Sœurs/Conjoints à bord: {siblings_spouses}, Parents/Enfants à bord: {parents_children}, Tarif: {fare}")
|
| 13 |
-
|
| 14 |
data = {
|
| 15 |
'Pclass': int(pclass),
|
| 16 |
'Sex_male': int(sex_male),
|
|
@@ -22,11 +19,9 @@ def predict(pclass, sex_male, age, siblings_spouses, parents_children, fare):
|
|
| 22 |
df = pd.DataFrame([data])
|
| 23 |
prediction = model.predict(df)
|
| 24 |
survival = int(prediction[0])
|
| 25 |
-
print(f"Prédiction: {survival}")
|
| 26 |
return survival
|
| 27 |
except Exception as e:
|
| 28 |
-
|
| 29 |
-
return gr.Error(str(e))
|
| 30 |
|
| 31 |
# Créer l'interface Gradio
|
| 32 |
gradio_app = gr.Blocks()
|
|
|
|
| 8 |
# Fonction pour faire la prédiction
|
| 9 |
def predict(pclass, sex_male, age, siblings_spouses, parents_children, fare):
|
| 10 |
try:
|
|
|
|
|
|
|
|
|
|
| 11 |
data = {
|
| 12 |
'Pclass': int(pclass),
|
| 13 |
'Sex_male': int(sex_male),
|
|
|
|
| 19 |
df = pd.DataFrame([data])
|
| 20 |
prediction = model.predict(df)
|
| 21 |
survival = int(prediction[0])
|
|
|
|
| 22 |
return survival
|
| 23 |
except Exception as e:
|
| 24 |
+
return gr.Error(f"Une erreur s'est produite : {str(e)}")
|
|
|
|
| 25 |
|
| 26 |
# Créer l'interface Gradio
|
| 27 |
gradio_app = gr.Blocks()
|