Spaces:
Sleeping
Sleeping
Upload processing.py
Browse files- processing.py +14 -8
processing.py
CHANGED
|
@@ -63,22 +63,28 @@ def map_statut_expert(p2):
|
|
| 63 |
# --- 3. PRÉPARATION DES DONNÉES (La version robuste) ---
|
| 64 |
|
| 65 |
def prepare_input(data):
|
| 66 |
-
#
|
|
|
|
| 67 |
df = pd.DataFrame(0.0, index=[0], columns=FEATURES)
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
else:
|
| 72 |
-
|
|
|
|
| 73 |
|
| 74 |
df['Tranche_effectif_num'] = float(data.get('Tranche_effectif_num', 0))
|
| 75 |
df['is_ess'] = int(data.get('is_ess', 0))
|
| 76 |
|
| 77 |
-
#
|
| 78 |
code_dep = str(data.get('code_departement', '')).strip().upper()
|
| 79 |
df['risque_departemental'] = float(DEP_RISK_MAP.get(code_dep, 0.05))
|
| 80 |
|
| 81 |
-
#
|
| 82 |
code_ape = str(data.get('code_ape', '')).zfill(2)
|
| 83 |
section_name = APE_SECTION_MAP.get(code_ape)
|
| 84 |
|
|
@@ -89,7 +95,7 @@ def prepare_input(data):
|
|
| 89 |
elif 'APE_Autres_Secteurs' in df.columns:
|
| 90 |
df['APE_Autres_Secteurs'] = 1.0
|
| 91 |
|
| 92 |
-
#
|
| 93 |
cj_prefix = str(data.get('categorie_juridique', ''))[:4]
|
| 94 |
col_cj = f"CJ_{cj_prefix}"
|
| 95 |
if col_cj in df.columns:
|
|
|
|
| 63 |
# --- 3. PRÉPARATION DES DONNÉES (La version robuste) ---
|
| 64 |
|
| 65 |
def prepare_input(data):
|
| 66 |
+
# 1. Création du DataFrame avec les colonnes exactes définies dans FEATURES
|
| 67 |
+
# FEATURES doit contenir 'age_au_diagnostic' (vérifie ton Secret HF !)
|
| 68 |
df = pd.DataFrame(0.0, index=[0], columns=FEATURES)
|
| 69 |
+
|
| 70 |
+
# 2. Variables numériques directes
|
| 71 |
+
# On prend 'age_estime' qui vient du Streamlit et on le met dans 'age_au_diagnostic'
|
| 72 |
+
valeur_age = float(data.get('age_estime', 0))
|
| 73 |
+
|
| 74 |
+
if 'age_au_diagnostic' in df.columns:
|
| 75 |
+
df['age_au_diagnostic'] = valeur_age
|
| 76 |
else:
|
| 77 |
+
# Si par hasard ton secret FEATURES contient 'age_estime'
|
| 78 |
+
df['age_estime'] = valeur_age
|
| 79 |
|
| 80 |
df['Tranche_effectif_num'] = float(data.get('Tranche_effectif_num', 0))
|
| 81 |
df['is_ess'] = int(data.get('is_ess', 0))
|
| 82 |
|
| 83 |
+
# 3. GESTION DU DÉPARTEMENT
|
| 84 |
code_dep = str(data.get('code_departement', '')).strip().upper()
|
| 85 |
df['risque_departemental'] = float(DEP_RISK_MAP.get(code_dep, 0.05))
|
| 86 |
|
| 87 |
+
# 4. Mapping APE
|
| 88 |
code_ape = str(data.get('code_ape', '')).zfill(2)
|
| 89 |
section_name = APE_SECTION_MAP.get(code_ape)
|
| 90 |
|
|
|
|
| 95 |
elif 'APE_Autres_Secteurs' in df.columns:
|
| 96 |
df['APE_Autres_Secteurs'] = 1.0
|
| 97 |
|
| 98 |
+
# 5. Mapping Catégorie Juridique
|
| 99 |
cj_prefix = str(data.get('categorie_juridique', ''))[:4]
|
| 100 |
col_cj = f"CJ_{cj_prefix}"
|
| 101 |
if col_cj in df.columns:
|