update
Browse files
app.py
CHANGED
|
@@ -10,7 +10,7 @@ try:
|
|
| 10 |
except FileNotFoundError:
|
| 11 |
raise FileNotFoundError(f"Le fichier modèle '{model_path}' est introuvable. Vérifiez le chemin.")
|
| 12 |
|
| 13 |
-
# Fonction de prédiction
|
| 14 |
def predict_price(kms_driven, present_price, fuel_type, seller_type, transmission, age):
|
| 15 |
# Encodage des variables catégoriques
|
| 16 |
fuel_type_mapping = {"Petrol": 0, "Diesel": 1, "CNG": 2}
|
|
@@ -72,7 +72,7 @@ def predict_from_csv(file):
|
|
| 72 |
except Exception as e:
|
| 73 |
return f"Erreur lors de la prédiction : {str(e)}"
|
| 74 |
|
| 75 |
-
# Interface Gradio pour la prédiction
|
| 76 |
simple_input_labels = [
|
| 77 |
gr.Number(label="Kms_Driven"),
|
| 78 |
gr.Number(label="Present_Price"),
|
|
@@ -85,7 +85,7 @@ simple_output = gr.Number(label="Predicted Price")
|
|
| 85 |
|
| 86 |
# Interface Gradio pour la prédiction multiple via un fichier CSV
|
| 87 |
csv_input = gr.File(label="Déposez votre fichier CSV")
|
| 88 |
-
csv_output = gr.Dataframe(label="Prédictions
|
| 89 |
|
| 90 |
# Interface combinée
|
| 91 |
interface = gr.TabbedInterface(
|
|
@@ -94,18 +94,18 @@ interface = gr.TabbedInterface(
|
|
| 94 |
fn=predict_price,
|
| 95 |
inputs=simple_input_labels,
|
| 96 |
outputs=simple_output,
|
| 97 |
-
title="Car Price Prediction (
|
| 98 |
description="Prédisez le prix d'une voiture en entrant une seule série de caractéristiques.",
|
| 99 |
),
|
| 100 |
gr.Interface(
|
| 101 |
fn=predict_from_csv,
|
| 102 |
inputs=csv_input,
|
| 103 |
outputs=csv_output,
|
| 104 |
-
title="Car Price Prediction (Multiple
|
| 105 |
-
description="
|
| 106 |
),
|
| 107 |
],
|
| 108 |
-
tab_names=["Prédiction
|
| 109 |
)
|
| 110 |
|
| 111 |
# Lancer l'application
|
|
|
|
| 10 |
except FileNotFoundError:
|
| 11 |
raise FileNotFoundError(f"Le fichier modèle '{model_path}' est introuvable. Vérifiez le chemin.")
|
| 12 |
|
| 13 |
+
# Fonction de prédiction unique
|
| 14 |
def predict_price(kms_driven, present_price, fuel_type, seller_type, transmission, age):
|
| 15 |
# Encodage des variables catégoriques
|
| 16 |
fuel_type_mapping = {"Petrol": 0, "Diesel": 1, "CNG": 2}
|
|
|
|
| 72 |
except Exception as e:
|
| 73 |
return f"Erreur lors de la prédiction : {str(e)}"
|
| 74 |
|
| 75 |
+
# Interface Gradio pour la prédiction unique
|
| 76 |
simple_input_labels = [
|
| 77 |
gr.Number(label="Kms_Driven"),
|
| 78 |
gr.Number(label="Present_Price"),
|
|
|
|
| 85 |
|
| 86 |
# Interface Gradio pour la prédiction multiple via un fichier CSV
|
| 87 |
csv_input = gr.File(label="Déposez votre fichier CSV")
|
| 88 |
+
csv_output = gr.Dataframe(label="Prédictions avec fichier CSV")
|
| 89 |
|
| 90 |
# Interface combinée
|
| 91 |
interface = gr.TabbedInterface(
|
|
|
|
| 94 |
fn=predict_price,
|
| 95 |
inputs=simple_input_labels,
|
| 96 |
outputs=simple_output,
|
| 97 |
+
title="Car Price Prediction (Unique)",
|
| 98 |
description="Prédisez le prix d'une voiture en entrant une seule série de caractéristiques.",
|
| 99 |
),
|
| 100 |
gr.Interface(
|
| 101 |
fn=predict_from_csv,
|
| 102 |
inputs=csv_input,
|
| 103 |
outputs=csv_output,
|
| 104 |
+
title="Car Price Prediction (Multiple)",
|
| 105 |
+
description="Téléversez un fichier CSV contenant les données des voitures pour obtenir les prédictions de prix.",
|
| 106 |
),
|
| 107 |
],
|
| 108 |
+
tab_names=["Prédiction Unique", "Prédiction Multiple"]
|
| 109 |
)
|
| 110 |
|
| 111 |
# Lancer l'application
|