avraux commited on
Commit ·
aee4d3a
1
Parent(s): f280f60
bug corrigé
Browse files- inference.py +8 -4
inference.py
CHANGED
|
@@ -18,7 +18,7 @@ def preprocess_and_predict(input_json):
|
|
| 18 |
"masse_ordma_max": 1500,
|
| 19 |
"marque": "BMW",
|
| 20 |
"typ_boite": "A 5",
|
| 21 |
-
"champ_v9":
|
| 22 |
"carrosserie": "COUPE",
|
| 23 |
"gamme": "LUXE"
|
| 24 |
}
|
|
@@ -29,17 +29,17 @@ def preprocess_and_predict(input_json):
|
|
| 29 |
|
| 30 |
# Mapper les catégories aux colonnes du modèle
|
| 31 |
marque_mapping = ["BMW", "MERCEDES", "VOLKSWAGEN"]
|
| 32 |
-
typ_boite_mapping = ["A 5", "A 6"]
|
| 33 |
carrosserie_mapping = ["BREAK", "COUPE", "MINIBUS", "TS TERRAINS/CHEMINS"]
|
| 34 |
gamme_mapping = ["INFERIEURE", "LUXE", "MOY-INFERIEURE", "MOY-SUPER", "SUPERIEURE"]
|
|
|
|
| 35 |
|
| 36 |
# Initialiser un dictionnaire pour construire les colonnes nécessaires
|
| 37 |
processed_data = {
|
| 38 |
"puiss_admin_98": input_json.get("puiss_admin_98", 0),
|
| 39 |
"conso_urb": input_json.get("conso_urb", 0.0),
|
| 40 |
"conso_exurb": input_json.get("conso_exurb", 0.0),
|
| 41 |
-
"masse_ordma_max": input_json.get("masse_ordma_max", 0.0)
|
| 42 |
-
"champ_v9": input_json.get("champ_v9", False),
|
| 43 |
}
|
| 44 |
|
| 45 |
# Variables indicatrices pour la marque
|
|
@@ -50,6 +50,10 @@ def preprocess_and_predict(input_json):
|
|
| 50 |
for typ_boite in typ_boite_mapping:
|
| 51 |
processed_data[f"typ_boite_nb_rapp_{typ_boite}"] = 1 if input_json.get("typ_boite") == typ_boite else 0
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
# Variables indicatrices pour la carrosserie
|
| 54 |
for carrosserie in carrosserie_mapping:
|
| 55 |
processed_data[f"Carrosserie_{carrosserie}"] = 1 if input_json.get("carrosserie") == carrosserie else 0
|
|
|
|
| 18 |
"masse_ordma_max": 1500,
|
| 19 |
"marque": "BMW",
|
| 20 |
"typ_boite": "A 5",
|
| 21 |
+
"champ_v9": 715/2007*195/2013EURO5,
|
| 22 |
"carrosserie": "COUPE",
|
| 23 |
"gamme": "LUXE"
|
| 24 |
}
|
|
|
|
| 29 |
|
| 30 |
# Mapper les catégories aux colonnes du modèle
|
| 31 |
marque_mapping = ["BMW", "MERCEDES", "VOLKSWAGEN"]
|
| 32 |
+
typ_boite_mapping = ["A 5", "A 6", "A 7", "A 8", "M 5", "M 6"]
|
| 33 |
carrosserie_mapping = ["BREAK", "COUPE", "MINIBUS", "TS TERRAINS/CHEMINS"]
|
| 34 |
gamme_mapping = ["INFERIEURE", "LUXE", "MOY-INFERIEURE", "MOY-SUPER", "SUPERIEURE"]
|
| 35 |
+
champ_v9_mapping = ["\"715/2007*195/2013EURO5", "\"715/2007*195/2013EURO6", "\"715/2007*566/2011EURO5", "\"715/2007*630/2012EURO5", "715/2007*195/2013EURO5", "715/2007*630/2012EURO5", "715/2007*692/2008EURO5"]
|
| 36 |
|
| 37 |
# Initialiser un dictionnaire pour construire les colonnes nécessaires
|
| 38 |
processed_data = {
|
| 39 |
"puiss_admin_98": input_json.get("puiss_admin_98", 0),
|
| 40 |
"conso_urb": input_json.get("conso_urb", 0.0),
|
| 41 |
"conso_exurb": input_json.get("conso_exurb", 0.0),
|
| 42 |
+
"masse_ordma_max": input_json.get("masse_ordma_max", 0.0)
|
|
|
|
| 43 |
}
|
| 44 |
|
| 45 |
# Variables indicatrices pour la marque
|
|
|
|
| 50 |
for typ_boite in typ_boite_mapping:
|
| 51 |
processed_data[f"typ_boite_nb_rapp_{typ_boite}"] = 1 if input_json.get("typ_boite") == typ_boite else 0
|
| 52 |
|
| 53 |
+
# Variables indicatrices pour la norme champ
|
| 54 |
+
for champ_v9 in champ_v9_mapping:
|
| 55 |
+
processed_data[f"champ_v9_{champ_v9}"] = 1 if input_json.get("champ_v9") == champ_v9 else 0
|
| 56 |
+
|
| 57 |
# Variables indicatrices pour la carrosserie
|
| 58 |
for carrosserie in carrosserie_mapping:
|
| 59 |
processed_data[f"Carrosserie_{carrosserie}"] = 1 if input_json.get("carrosserie") == carrosserie else 0
|