Diaure commited on
Commit
89b0184
·
verified ·
1 Parent(s): 09dbc8e

CD: update from GitHub main

Browse files
Monitoring/dashboard.py CHANGED
@@ -12,12 +12,17 @@ st.set_page_config(page_title="Monitoring Drift", layout="wide")
12
  with open("Monitoring/drift_report.json", "r", encoding="utf-8") as f:
13
  drift_data = json.load(f)
14
 
15
- # Tests pour vérifier la structure du json drift
16
  # for m in drift_data["metrics"]:
17
  # if m["metric"] == "ColumnSummaryMetric":
18
  # st.json(m)
19
  # break
20
 
 
 
 
 
 
21
  # for m in drift_data["metrics"]:
22
  # if m["metric"] == "ColumnSummaryMetric":
23
  # print("======")
@@ -50,7 +55,7 @@ df_logs_opti["timestamp_model"] = pd.to_datetime(df_logs_opti["timestamp_model"]
50
  st.title("📊 Monitoring du Drift — Dashboard MLOps")
51
 
52
  # ONGLET 1 — Vue d’ensemble
53
- tab1, tab2, tab3, tab4, tab5, tab6 = st.tabs(["VUE D'ENSEMBLE", "DERIVE PAR COLONNE", "RESUME PAR COLONNE", "LOGS BRUTS", "IMPACT OPTIMISATION", "COMPARAISON UNITAIRE vs BATCH"])
54
 
55
  with tab1:
56
  # Colonnes en dérive - Résultat global
@@ -162,8 +167,6 @@ with tab2:
162
  "missing_pct": result["current_characteristics"]["missing_percentage"],
163
  "unique": result["current_characteristics"]["unique"]}
164
 
165
- # print(list(summary_dict.keys())[:5])
166
-
167
  drift_rows = []
168
  for m in drift_data["metrics"]:
169
  if m["metric"] != "ColumnDriftMetric":
@@ -186,10 +189,13 @@ with tab2:
186
  "Nombre de valeurs uniques": summary_dict[col]["unique"]})
187
 
188
  df_drift = pd.DataFrame(drift_rows)
189
- st.dataframe(df_drift.sort_values("Distance drift", ascending = False), width = "stretch")
 
190
 
191
- selected_col = st.selectbox("Choisir une colonne", df_drift["Colonne"], key = "drift_column")
192
 
 
 
193
  metric = next(m for m in drift_data["metrics"]if (m["metric"] == "ColumnDriftMetric" and m["result"]["column_name"] == selected_col))
194
  x_ref = metric["result"]["reference"]["small_distribution"]["x"]
195
  y_ref = metric["result"]["reference"]["small_distribution"]["y"]
@@ -203,6 +209,14 @@ with tab2:
203
 
204
  with st.container():
205
  st.write(f"Analyse détaillée: {selected_col}")
 
 
 
 
 
 
 
 
206
  d1, d2 = st.columns([1,1])
207
 
208
  # Distribution des données
@@ -221,78 +235,52 @@ with tab2:
221
  d2.plotly_chart(fig_missing, width = "stretch")
222
 
223
  # ONGLET 3 — Résumé par colonne (finalement faire plutôt un tableau?)
224
- with tab3:
225
- st.header("📘 Résumé statistique par colonne")
226
 
227
- summaries = {}
228
- for m in drift_data["metrics"]:
229
- if m["metric"] != "ColumnSummaryMetric":
230
- continue
 
 
 
 
 
231
 
232
- result2 = m['result']
233
- summaries[result2["column_name"]] = result2
234
-
235
- col_selectione = st.selectbox("Choisir une colonne", sorted(summaries.keys()))
236
- summary = summaries[col_selectione]
237
-
238
- ref = summary["reference_characteristics"]
239
- cur = summary["current_characteristics"]
240
-
241
- # col = result2["column_name"]
242
- st.subheader(f"🔹 {col_selectione}")
243
- col1, col2 = st.columns(2)
244
-
245
- with col1:
246
- st.markdown("### Référence")
247
- st.dataframe(pd.DataFrame(ref.items(), columns=["Métrique", "Valeur"]), width = True)
248
-
249
- with col2:
250
- st.markdown("### Production")
251
- st.dataframe(pd.DataFrame(cur.items(), columns=["Métrique", "Valeur"]), width = True)
252
-
253
- # comparaison synthétique
254
- compare_df = pd.DataFrame({
255
- "Métrique": [
256
- "count",
257
- "missing",
258
- "mean",
259
- "std",
260
- "min",
261
- "p25",
262
- "p50",
263
- "p75",
264
- "max",
265
- "unique"],
266
-
267
- "Référence": [
268
- ref.get("count"),
269
- ref.get("missing"),
270
- ref.get("mean"),
271
- ref.get("std"),
272
- ref.get("min"),
273
- ref.get("p25"),
274
- ref.get("p50"),
275
- ref.get("p75"),
276
- ref.get("max"),
277
- ref.get("unique")],
278
-
279
- "Production": [
280
- cur.get("count"),
281
- cur.get("missing"),
282
- cur.get("mean"),
283
- cur.get("std"),
284
- cur.get("min"),
285
- cur.get("p25"),
286
- cur.get("p50"),
287
- cur.get("p75"),
288
- cur.get("max"),
289
- cur.get("unique")]})
290
-
291
- st.markdown("### Comparaison directe")
292
- st.dataframe(compare_df, width = True)
293
 
294
  # ONGLET 4 — Logs bruts
295
- with tab4:
296
  st.header("📄 Logs bruts (production)")
297
 
298
  st.dataframe(df_logs.head(200))
@@ -300,10 +288,10 @@ with tab4:
300
  col = st.selectbox("Visualiser une colonne :", df_logs.columns)
301
 
302
  fig = px.histogram(df_logs, x=col, nbins=30, title=f"Distribution de {col}")
303
- st.plotly_chart(fig, width=True)
304
 
305
  # ONGLET 5 - KPI API après optimisation du processing
306
- with tab5:
307
  # KPI API
308
  with st.container():
309
  st.markdown("""<p style='font-size: 22px; font-style: italic;'>Performance API (Batch)</p>""", unsafe_allow_html=True)
@@ -340,7 +328,7 @@ with tab5:
340
  st.plotly_chart(fig, use_container_width=True)
341
 
342
  # ONGLET 6 - Compaaison des kpis avant et après optimisation
343
- with tab6:
344
  if df_logs.empty or df_logs_opti.empty:
345
  st.warning("Exécute au moins une requête unitaire et un batch pour afficher la comparaison.")
346
  else:
@@ -370,7 +358,7 @@ with tab6:
370
  df_batch["threads"] = df_batch["num_threads_ops"]
371
 
372
  # KPI
373
- st.subheader("⏱️ Performances par client")
374
  p1, p2, p3 = st.columns([1,1,1])
375
 
376
  # st.markdown("""<p style='font-size: 22px; font-style: italic;'>Latence par client</p>""", unsafe_allow_html=True)
@@ -388,7 +376,7 @@ with tab6:
388
  st.markdown("<br>", unsafe_allow_html=True)
389
 
390
  # kpi CPU/RAM/LOAD/THREADS
391
- st.subheader("🖥️ Charge système")
392
 
393
  s1, s2, s3, s4 = st.columns([1,1,1,1])
394
  s1.metric("CPU (%) unitaire", f"{df_unit['cpu'].mean():.1f}%")
@@ -404,7 +392,7 @@ with tab6:
404
  st.markdown("<hr>", unsafe_allow_html=True)
405
 
406
  # Graphiques comparatifs
407
- st.subheader("📊 Visualisations comparatives")
408
 
409
  c1, c2 = st.columns(2)
410
 
 
12
  with open("Monitoring/drift_report.json", "r", encoding="utf-8") as f:
13
  drift_data = json.load(f)
14
 
15
+ # # Tests pour vérifier la structure du json drift
16
  # for m in drift_data["metrics"]:
17
  # if m["metric"] == "ColumnSummaryMetric":
18
  # st.json(m)
19
  # break
20
 
21
+ # for m in drift_data["metrics"]:
22
+ # if m["metric"] == "ColumnSummaryMetric":
23
+ # st.write(m)
24
+ # break
25
+
26
  # for m in drift_data["metrics"]:
27
  # if m["metric"] == "ColumnSummaryMetric":
28
  # print("======")
 
55
  st.title("📊 Monitoring du Drift — Dashboard MLOps")
56
 
57
  # ONGLET 1 — Vue d’ensemble
58
+ tab1, tab2, tab3, tab4, tab5 = st.tabs(["VUE D'ENSEMBLE", "DERIVE PAR COLONNE", "LOGS BRUTS", "IMPACT OPTIMISATION", "COMPARAISON UNITAIRE vs BATCH"])
59
 
60
  with tab1:
61
  # Colonnes en dérive - Résultat global
 
167
  "missing_pct": result["current_characteristics"]["missing_percentage"],
168
  "unique": result["current_characteristics"]["unique"]}
169
 
 
 
170
  drift_rows = []
171
  for m in drift_data["metrics"]:
172
  if m["metric"] != "ColumnDriftMetric":
 
189
  "Nombre de valeurs uniques": summary_dict[col]["unique"]})
190
 
191
  df_drift = pd.DataFrame(drift_rows)
192
+ df_drift_filtered = (df_drift[df_drift["Drift détecté"] == True].drop_duplicates(subset=["Colonne"])) # uniquement les colonnes en dérive pour voir le taux de dérive par colonne
193
+ # st.dataframe(df_drift_filtered.sort_values("Distance drift", ascending = False), width = "stretch")
194
 
195
+ selected_col = st.selectbox("Choisir une colonne", df_drift_filtered["Colonne"], key = "drift_column")
196
 
197
+ col_stats = df_drift_filtered[df_drift_filtered["Colonne"] == selected_col].iloc[0]
198
+
199
  metric = next(m for m in drift_data["metrics"]if (m["metric"] == "ColumnDriftMetric" and m["result"]["column_name"] == selected_col))
200
  x_ref = metric["result"]["reference"]["small_distribution"]["x"]
201
  y_ref = metric["result"]["reference"]["small_distribution"]["y"]
 
209
 
210
  with st.container():
211
  st.write(f"Analyse détaillée: {selected_col}")
212
+
213
+ st.markdown(f"""
214
+ - **Distance drift** : `{col_stats['Distance drift']:.4f}`
215
+ - **Dérive (%)** : `{col_stats['Dérive(%)']} %`
216
+ - **Seuil (%)** : `{col_stats['Seuil(%)']} %`
217
+ - **Drift détecté** : `{"Oui" if col_stats['Drift détecté'] else "Non"}`
218
+ """)
219
+
220
  d1, d2 = st.columns([1,1])
221
 
222
  # Distribution des données
 
235
  d2.plotly_chart(fig_missing, width = "stretch")
236
 
237
  # ONGLET 3 — Résumé par colonne (finalement faire plutôt un tableau?)
238
+ # with tab3:
239
+ # st.header("📘 Résumé statistique par colonne")
240
 
241
+ # summaries = {}
242
+ # for m in drift_data["metrics"]:
243
+ # if m["metric"] != "ColumnSummaryMetric":
244
+ # continue
245
+ # result2 = m['result']
246
+
247
+ # if ("column_name" not in result2 or result2["column_name"] is None or "reference_characteristics" not in result2 or "current_characteristics" not in result2):
248
+ # continue
249
+ # summaries[result2["column_name"]] = result2
250
 
251
+ # options = sorted(summaries.keys())
252
+
253
+ # col_selectione = st.selectbox("Choisir une colonne", options, index=0)
254
+ # # col_selectione = st.selectbox("Choisir une colonne", sorted(summaries.keys()), key="summary_column")
255
+
256
+ # summary = summaries[col_selectione]
257
+ # ref = summary["reference_characteristics"]
258
+ # cur = summary["current_characteristics"]
259
+
260
+ # st.subheader(f"🔹 {col_selectione}")
261
+ # col1, col2 = st.columns(2)
262
+
263
+ # with col1:
264
+ # st.markdown("### Référence")
265
+ # st.dataframe(pd.DataFrame(ref.items(), columns=["Métrique", "Valeur"]), width = True)
266
+
267
+ # with col2:
268
+ # st.markdown("### Production")
269
+ # st.dataframe(pd.DataFrame(cur.items(), columns=["Métrique", "Valeur"]), width = True)
270
+
271
+ # # comparaison synthétique
272
+ # compare_df = pd.DataFrame({
273
+ # "Métrique": ["count", "missing", "mean", "std", "min", "p25", "p50", "p75", "max", "unique"],
274
+ # "Référence": [ref.get("count"), ref.get("missing"), ref.get("mean"), ref.get("std"), ref.get("min"), ref.get("p25"),
275
+ # ref.get("p50"), ref.get("p75"), ref.get("max"), ref.get("unique")],
276
+ # "Production": [cur.get("count"), cur.get("missing"), cur.get("mean"), cur.get("std"), cur.get("min"), cur.get("p25"),
277
+ # cur.get("p50"), cur.get("p75"), cur.get("max"), cur.get("unique")]})
278
+
279
+ # st.markdown("### Comparaison directe")
280
+ # st.dataframe(compare_df, width = True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
 
282
  # ONGLET 4 — Logs bruts
283
+ with tab3:
284
  st.header("📄 Logs bruts (production)")
285
 
286
  st.dataframe(df_logs.head(200))
 
288
  col = st.selectbox("Visualiser une colonne :", df_logs.columns)
289
 
290
  fig = px.histogram(df_logs, x=col, nbins=30, title=f"Distribution de {col}")
291
+ st.plotly_chart(fig, width="stretch")
292
 
293
  # ONGLET 5 - KPI API après optimisation du processing
294
+ with tab4:
295
  # KPI API
296
  with st.container():
297
  st.markdown("""<p style='font-size: 22px; font-style: italic;'>Performance API (Batch)</p>""", unsafe_allow_html=True)
 
328
  st.plotly_chart(fig, use_container_width=True)
329
 
330
  # ONGLET 6 - Compaaison des kpis avant et après optimisation
331
+ with tab5:
332
  if df_logs.empty or df_logs_opti.empty:
333
  st.warning("Exécute au moins une requête unitaire et un batch pour afficher la comparaison.")
334
  else:
 
358
  df_batch["threads"] = df_batch["num_threads_ops"]
359
 
360
  # KPI
361
+ st.subheader("Performances par client")
362
  p1, p2, p3 = st.columns([1,1,1])
363
 
364
  # st.markdown("""<p style='font-size: 22px; font-style: italic;'>Latence par client</p>""", unsafe_allow_html=True)
 
376
  st.markdown("<br>", unsafe_allow_html=True)
377
 
378
  # kpi CPU/RAM/LOAD/THREADS
379
+ st.subheader("Charge système")
380
 
381
  s1, s2, s3, s4 = st.columns([1,1,1,1])
382
  s1.metric("CPU (%) unitaire", f"{df_unit['cpu'].mean():.1f}%")
 
392
  st.markdown("<hr>", unsafe_allow_html=True)
393
 
394
  # Graphiques comparatifs
395
+ st.subheader("Visualisations comparatives")
396
 
397
  c1, c2 = st.columns(2)
398
 
Monitoring/drift_report.html CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:921f3a61e33836692e702a557ff0d2fb276688eca5660007d4e21c7674ba0400
3
- size 12368839
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:75bec8f2bd82a6fb7675224cf92e73d238ca0ac3f7a697b476f90de1de7483e3
3
+ size 21279876
Monitoring/drift_report.json CHANGED
The diff for this file is too large to render. See raw diff
 
Monitoring/test_drift.py CHANGED
@@ -4,42 +4,25 @@ import joblib
4
  from evidently.report import Report
5
  from evidently.metrics import ColumnDriftMetric
6
 
7
- # =========================
8
  # Chargement des données
9
- # =========================
10
 
11
  pipe = joblib.load("./BestModel/pipeline_complet.joblib")
12
  df_example = joblib.load("./data/app_test_clean_v2.joblib")
13
 
14
  expected_cols = pipe.feature_names_in_
15
-
16
  df_reference = df_example[expected_cols].copy()
 
17
 
18
- df_production = pd.read_parquet(
19
- "logs/predictions_log.parquet"
20
- )
21
-
22
- # =========================
23
  # Colonnes communes
24
- # =========================
25
-
26
  df_reference.columns = df_reference.columns.astype(str)
27
  df_production.columns = df_production.columns.astype(str)
28
 
29
- common_cols = sorted(
30
- set(df_reference.columns)
31
- .intersection(df_production.columns)
32
- )
33
-
34
  df_reference = df_reference[common_cols].copy()
35
  df_production = df_production[common_cols].copy()
36
 
37
- # =========================
38
  # Harmonisation des types
39
- # =========================
40
-
41
  for col in common_cols:
42
-
43
  # bool -> int
44
  if df_reference[col].dtype == bool:
45
  df_reference[col] = df_reference[col].astype(int)
@@ -52,104 +35,43 @@ for col in common_cols:
52
 
53
  # Les deux numériques
54
  if ref_num and prod_num:
55
-
56
- df_reference[col] = (
57
- pd.to_numeric(
58
- df_reference[col],
59
- errors="coerce"
60
- )
61
- .astype("float64")
62
- )
63
-
64
- df_production[col] = (
65
- pd.to_numeric(
66
- df_production[col],
67
- errors="coerce"
68
- )
69
- .astype("float64")
70
- )
71
 
72
  # Sinon tout en string
73
  else:
 
 
74
 
75
- df_reference[col] = (
76
- df_reference[col]
77
- .fillna("MISSING")
78
- .astype(str)
79
- )
80
-
81
- df_production[col] = (
82
- df_production[col]
83
- .fillna("MISSING")
84
- .astype(str)
85
- )
86
-
87
- # =========================
88
  # Suppression colonnes vides
89
- # =========================
90
-
91
  valid_cols = []
92
-
93
  for col in common_cols:
94
-
95
- if (
96
- df_reference[col].notna().sum() > 0
97
- and
98
- df_production[col].notna().sum() > 0
99
- ):
100
  valid_cols.append(col)
101
-
102
  df_reference = df_reference[valid_cols]
103
  df_production = df_production[valid_cols]
104
 
105
- # =========================
106
  # Suppression colonnes constantes
107
- # =========================
108
-
109
  non_constant_cols = []
110
-
111
  for col in valid_cols:
112
-
113
- if (
114
- df_reference[col].nunique(dropna=True) > 1
115
- and
116
- df_production[col].nunique(dropna=True) > 1
117
- ):
118
  non_constant_cols.append(col)
119
-
120
  df_reference = df_reference[non_constant_cols]
121
  df_production = df_production[non_constant_cols]
122
 
123
  print(f"\nNombre de colonnes testées : {len(non_constant_cols)}")
124
 
125
- # =========================
126
  # Test colonne par colonne
127
- # =========================
128
-
129
  for col in non_constant_cols:
130
-
131
  print(f"\nTest : {col}")
132
-
133
  try:
134
-
135
- report = Report(
136
- metrics=[
137
- ColumnDriftMetric(column_name=col)
138
- ]
139
- )
140
-
141
- report.run(
142
- reference_data=df_reference[[col]],
143
- current_data=df_production[[col]]
144
- )
145
-
146
  print("OK")
147
-
148
  except Exception as e:
149
-
150
- print("\n===================================")
151
  print(f"COLONNE EN ERREUR : {col}")
152
- print("===================================")
153
 
154
  print("\nType référence :")
155
  print(df_reference[col].dtype)
@@ -158,22 +80,9 @@ for col in non_constant_cols:
158
  print(df_production[col].dtype)
159
 
160
  print("\nTypes Python REF :")
161
- print(
162
- set(
163
- df_reference[col]
164
- .dropna()
165
- .map(type)
166
- )
167
- )
168
-
169
  print("\nTypes Python PROD :")
170
- print(
171
- set(
172
- df_production[col]
173
- .dropna()
174
- .map(type)
175
- )
176
- )
177
 
178
  print("\nException :")
179
  print(e)
 
4
  from evidently.report import Report
5
  from evidently.metrics import ColumnDriftMetric
6
 
 
7
  # Chargement des données
 
8
 
9
  pipe = joblib.load("./BestModel/pipeline_complet.joblib")
10
  df_example = joblib.load("./data/app_test_clean_v2.joblib")
11
 
12
  expected_cols = pipe.feature_names_in_
 
13
  df_reference = df_example[expected_cols].copy()
14
+ df_production = pd.read_parquet("logs/predictions_log.parquet")
15
 
 
 
 
 
 
16
  # Colonnes communes
 
 
17
  df_reference.columns = df_reference.columns.astype(str)
18
  df_production.columns = df_production.columns.astype(str)
19
 
20
+ common_cols = sorted(set(df_reference.columns).intersection(df_production.columns))
 
 
 
 
21
  df_reference = df_reference[common_cols].copy()
22
  df_production = df_production[common_cols].copy()
23
 
 
24
  # Harmonisation des types
 
 
25
  for col in common_cols:
 
26
  # bool -> int
27
  if df_reference[col].dtype == bool:
28
  df_reference[col] = df_reference[col].astype(int)
 
35
 
36
  # Les deux numériques
37
  if ref_num and prod_num:
38
+ df_reference[col] = (pd.to_numeric(df_reference[col], errors="coerce").astype("float64"))
39
+ df_production[col] = (pd.to_numeric(df_production[col], errors="coerce").astype("float64"))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
  # Sinon tout en string
42
  else:
43
+ df_reference[col] = (df_reference[col].fillna("MISSING").astype(str))
44
+ df_production[col] = (df_production[col].fillna("MISSING").astype(str))
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  # Suppression colonnes vides
 
 
47
  valid_cols = []
 
48
  for col in common_cols:
49
+ if (df_reference[col].notna().sum() > 0 and df_production[col].notna().sum() > 0):
 
 
 
 
 
50
  valid_cols.append(col)
 
51
  df_reference = df_reference[valid_cols]
52
  df_production = df_production[valid_cols]
53
 
 
54
  # Suppression colonnes constantes
 
 
55
  non_constant_cols = []
 
56
  for col in valid_cols:
57
+ if (df_reference[col].nunique(dropna=True) > 1 and df_production[col].nunique(dropna=True) > 1):
 
 
 
 
 
58
  non_constant_cols.append(col)
 
59
  df_reference = df_reference[non_constant_cols]
60
  df_production = df_production[non_constant_cols]
61
 
62
  print(f"\nNombre de colonnes testées : {len(non_constant_cols)}")
63
 
 
64
  # Test colonne par colonne
 
 
65
  for col in non_constant_cols:
 
66
  print(f"\nTest : {col}")
 
67
  try:
68
+ report = Report(metrics = [ColumnDriftMetric(column_name = col)])
69
+ report.run(reference_data = df_reference[[col]], current_data = df_production[[col]])
 
 
 
 
 
 
 
 
 
 
70
  print("OK")
 
71
  except Exception as e:
72
+ print("\n-------------------------------------")
 
73
  print(f"COLONNE EN ERREUR : {col}")
74
+ print("-------------------------------------")
75
 
76
  print("\nType référence :")
77
  print(df_reference[col].dtype)
 
80
  print(df_production[col].dtype)
81
 
82
  print("\nTypes Python REF :")
83
+ print(set(df_reference[col].dropna().map(type)))
 
 
 
 
 
 
 
84
  print("\nTypes Python PROD :")
85
+ print(set(df_production[col].dropna().map(type)))
 
 
 
 
 
 
86
 
87
  print("\nException :")
88
  print(e)
Notesbooks/drift_performance_analysis.ipynb ADDED
@@ -0,0 +1,1428 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "aeb4cd48",
6
+ "metadata": {},
7
+ "source": [
8
+ "# **Analyse du drift & de la performance**\n",
9
+ "\n",
10
+ "Ce notebook a pour objectif :\n",
11
+ "\n",
12
+ "- **d’évaluer le data drift** entre :\n",
13
+ " - les données de référence (jeu d’entraînement ou échantillon représentatif)\n",
14
+ " - les données de production issues des logs de l’API\n",
15
+ "\n",
16
+ " Le data drift permet de détecter si les distributions des variables évoluent dans le temps. \n",
17
+ " Ces changements peuvent dégrader les performances du modèle, notamment lorsque les distributions de production s’éloignent de celles observées lors de l’entraînement.\n",
18
+ "\n",
19
+ " Pour cela, nous utilisons la librairie **Evidently AI**, qui permet d’analyser le drift **colonne par colonne**, après avoir soigneusement harmonisé les colonnes entre les deux jeux de données (types, valeurs manquantes, colonnes constantes, etc.).\n",
20
+ "\n",
21
+ "- **d’évaluer la performance du pipeline de prédiction**, non pas uniquement au niveau du modèle, mais surtout au niveau du **preprocessing**, afin d’identifier les véritables axes d’optimisation.\n",
22
+ "\n",
23
+ " En effet, dans un contexte MLOps, la latence d’un modèle en production dépend autant du modèle que du pipeline de transformation. \n",
24
+ " Nous mesurons donc :\n",
25
+ " - le temps de preprocessing,\n",
26
+ " - le temps de prédiction du modèle,\n",
27
+ " - la différence entre appels unitaires et prédiction en batch,\n",
28
+ " - et nous analysons les résultats du profiling pour identifier les goulots d’étranglement.\n",
29
+ "\n"
30
+ ]
31
+ },
32
+ {
33
+ "cell_type": "code",
34
+ "execution_count": 60,
35
+ "id": "ee429e61",
36
+ "metadata": {},
37
+ "outputs": [],
38
+ "source": [
39
+ "import pandas as pd\n",
40
+ "import cProfile\n",
41
+ "import pstats\n",
42
+ "import joblib\n",
43
+ "import time\n",
44
+ "\n",
45
+ "from evidently.report import Report\n",
46
+ "from evidently.metrics import ColumnDriftMetric"
47
+ ]
48
+ },
49
+ {
50
+ "cell_type": "markdown",
51
+ "id": "1149740f",
52
+ "metadata": {},
53
+ "source": [
54
+ "## **Analyse du Data Drift avec Evidently**"
55
+ ]
56
+ },
57
+ {
58
+ "cell_type": "code",
59
+ "execution_count": 61,
60
+ "id": "9a27a53d",
61
+ "metadata": {},
62
+ "outputs": [
63
+ {
64
+ "data": {
65
+ "text/plain": [
66
+ "((500, 327), (213, 406), (213, 406))"
67
+ ]
68
+ },
69
+ "execution_count": 61,
70
+ "metadata": {},
71
+ "output_type": "execute_result"
72
+ }
73
+ ],
74
+ "source": [
75
+ "# Chargement du pipeline\n",
76
+ "pipe = joblib.load(\"../BestModel/pipeline_complet.joblib\")\n",
77
+ "\n",
78
+ "# Données de référence (version simplifiée)\n",
79
+ "df_reference_raw = joblib.load(\"../data/app_test_small.joblib\")\n",
80
+ "\n",
81
+ "# Données de production (logs unitaires)\n",
82
+ "df_production_raw = pd.read_parquet(\"../logs/predictions_log.parquet\")\n",
83
+ "\n",
84
+ "# Données de production (logs batch)\n",
85
+ "df_batch_raw = pd.read_parquet(\"../logs/predictions_log.parquet\")\n",
86
+ "\n",
87
+ "df_reference_raw.shape, df_production_raw.shape, df_batch_raw.shape"
88
+ ]
89
+ },
90
+ {
91
+ "cell_type": "markdown",
92
+ "id": "276796a6",
93
+ "metadata": {},
94
+ "source": [
95
+ "### Sélection des colonnes communes entre référence production"
96
+ ]
97
+ },
98
+ {
99
+ "cell_type": "code",
100
+ "execution_count": 62,
101
+ "id": "a66434ea",
102
+ "metadata": {},
103
+ "outputs": [
104
+ {
105
+ "data": {
106
+ "text/plain": [
107
+ "Index(['num__SK_ID_CURR', 'num__BUREAU_SK_ID_BUREAU_max',\n",
108
+ " 'num__POS_SK_DPD_min', 'num__CC_SK_DPD_DEF_max',\n",
109
+ " 'num__PREV_NAME_TYPE_SUITE_Family', 'num__PREV_DAYS_FIRST_DRAWING_sum',\n",
110
+ " 'num__PREV_NAME_GOODS_CATEGORY_Other', 'num__DAYS_LAST_PHONE_CHANGE',\n",
111
+ " 'num__CC_CNT_DRAWINGS_OTHER_CURRENT_mean',\n",
112
+ " 'num__PREV_DAYS_FIRST_DRAWING_max',\n",
113
+ " ...\n",
114
+ " 'bool__FLAG_DOCUMENT_12', 'bool__FLAG_DOCUMENT_13',\n",
115
+ " 'bool__FLAG_DOCUMENT_14', 'bool__FLAG_DOCUMENT_15',\n",
116
+ " 'bool__FLAG_DOCUMENT_16', 'bool__FLAG_DOCUMENT_17',\n",
117
+ " 'bool__FLAG_DOCUMENT_18', 'bool__FLAG_DOCUMENT_19',\n",
118
+ " 'bool__FLAG_DOCUMENT_20', 'bool__FLAG_DOCUMENT_21'],\n",
119
+ " dtype='object', length=382)"
120
+ ]
121
+ },
122
+ "execution_count": 62,
123
+ "metadata": {},
124
+ "output_type": "execute_result"
125
+ }
126
+ ],
127
+ "source": [
128
+ "# Transformer les colonnes de référence\n",
129
+ "df_reference_transformed = pipe[:-1].transform(df_reference_raw)\n",
130
+ "df_reference_transformed = pd.DataFrame(df_reference_transformed, columns=pipe[:-1].get_feature_names_out())\n",
131
+ "df_reference_transformed.columns\n"
132
+ ]
133
+ },
134
+ {
135
+ "cell_type": "code",
136
+ "execution_count": 63,
137
+ "id": "e02ce960",
138
+ "metadata": {},
139
+ "outputs": [
140
+ {
141
+ "data": {
142
+ "text/plain": [
143
+ "Index(['num__SK_ID_CURR', 'num__BUREAU_SK_ID_BUREAU_max',\n",
144
+ " 'num__POS_SK_DPD_min', 'num__CC_SK_DPD_DEF_max',\n",
145
+ " 'num__PREV_NAME_TYPE_SUITE_Family', 'num__PREV_DAYS_FIRST_DRAWING_sum',\n",
146
+ " 'num__PREV_NAME_GOODS_CATEGORY_Other', 'num__DAYS_LAST_PHONE_CHANGE',\n",
147
+ " 'num__CC_CNT_DRAWINGS_OTHER_CURRENT_mean',\n",
148
+ " 'num__PREV_DAYS_FIRST_DRAWING_max',\n",
149
+ " ...\n",
150
+ " 'ram_percent', 'system_load', 'num_threads', 'method', 'status',\n",
151
+ " 'error_message', 'latency_ms', 'request_size_bytes',\n",
152
+ " 'response_size_bytes', 'batch_size_y'],\n",
153
+ " dtype='object', length=406)"
154
+ ]
155
+ },
156
+ "execution_count": 63,
157
+ "metadata": {},
158
+ "output_type": "execute_result"
159
+ }
160
+ ],
161
+ "source": [
162
+ "df_production_raw.columns"
163
+ ]
164
+ },
165
+ {
166
+ "cell_type": "code",
167
+ "execution_count": 64,
168
+ "id": "d9282066",
169
+ "metadata": {},
170
+ "outputs": [
171
+ {
172
+ "data": {
173
+ "text/plain": [
174
+ "382"
175
+ ]
176
+ },
177
+ "execution_count": 64,
178
+ "metadata": {},
179
+ "output_type": "execute_result"
180
+ }
181
+ ],
182
+ "source": [
183
+ "common_cols = df_reference_transformed.columns.intersection(df_production_raw.columns)\n",
184
+ "len(common_cols)"
185
+ ]
186
+ },
187
+ {
188
+ "cell_type": "code",
189
+ "execution_count": 65,
190
+ "id": "eb15c29d",
191
+ "metadata": {},
192
+ "outputs": [
193
+ {
194
+ "data": {
195
+ "text/plain": [
196
+ "((500, 382), (213, 382))"
197
+ ]
198
+ },
199
+ "execution_count": 65,
200
+ "metadata": {},
201
+ "output_type": "execute_result"
202
+ }
203
+ ],
204
+ "source": [
205
+ "df_reference = df_reference_transformed[common_cols].copy()\n",
206
+ "df_production = df_production_raw[common_cols].copy()\n",
207
+ "\n",
208
+ "df_reference.shape, df_production.shape"
209
+ ]
210
+ },
211
+ {
212
+ "cell_type": "markdown",
213
+ "id": "3b53669d",
214
+ "metadata": {},
215
+ "source": [
216
+ "### Harmonisation des colonnes"
217
+ ]
218
+ },
219
+ {
220
+ "cell_type": "code",
221
+ "execution_count": 66,
222
+ "id": "a0aee959",
223
+ "metadata": {},
224
+ "outputs": [],
225
+ "source": [
226
+ "for col in common_cols:\n",
227
+ " # bool → int\n",
228
+ " if df_reference[col].dtype == bool:\n",
229
+ " df_reference[col] = df_reference[col].astype(int)\n",
230
+ "\n",
231
+ " if df_production[col].dtype == bool:\n",
232
+ " df_production[col] = df_production[col].astype(int)\n",
233
+ "\n",
234
+ " ref_num = pd.api.types.is_numeric_dtype(df_reference[col])\n",
235
+ " prod_num = pd.api.types.is_numeric_dtype(df_production[col])\n",
236
+ "\n",
237
+ " # Les deux numériques\n",
238
+ " if ref_num and prod_num:\n",
239
+ " df_reference[col] = pd.to_numeric(df_reference[col], errors=\"coerce\").astype(\"float64\")\n",
240
+ " df_production[col] = pd.to_numeric(df_production[col], errors=\"coerce\").astype(\"float64\")\n",
241
+ "\n",
242
+ " # Sinon → string\n",
243
+ " else:\n",
244
+ " df_reference[col] = df_reference[col].fillna(\"MISSING\").astype(str)\n",
245
+ " df_production[col] = df_production[col].fillna(\"MISSING\").astype(str)\n"
246
+ ]
247
+ },
248
+ {
249
+ "cell_type": "markdown",
250
+ "id": "ec1bec15",
251
+ "metadata": {},
252
+ "source": [
253
+ "### Suppression des colonnes vides et constantes"
254
+ ]
255
+ },
256
+ {
257
+ "cell_type": "code",
258
+ "execution_count": 67,
259
+ "id": "078e82b0",
260
+ "metadata": {},
261
+ "outputs": [
262
+ {
263
+ "name": "stdout",
264
+ "output_type": "stream",
265
+ "text": [
266
+ "275\n",
267
+ "213\n",
268
+ "500\n"
269
+ ]
270
+ }
271
+ ],
272
+ "source": [
273
+ "valid_cols = [\n",
274
+ " col for col in common_cols\n",
275
+ " if df_reference[col].notna().sum() > 0 and df_production[col].notna().sum() > 0]\n",
276
+ "\n",
277
+ "non_constant_cols = [\n",
278
+ " col for col in valid_cols\n",
279
+ " if df_reference[col].nunique(dropna=True) > 1\n",
280
+ " and df_production[col].nunique(dropna=True) > 1]\n",
281
+ "\n",
282
+ "df_reference = df_reference[non_constant_cols]\n",
283
+ "df_production = df_production[non_constant_cols]\n",
284
+ "\n",
285
+ "print(len(non_constant_cols))\n",
286
+ "print(len(df_production))\n",
287
+ "print(len(df_reference))\n"
288
+ ]
289
+ },
290
+ {
291
+ "cell_type": "markdown",
292
+ "id": "a9f6fc6c",
293
+ "metadata": {},
294
+ "source": [
295
+ "### Drift par colonne"
296
+ ]
297
+ },
298
+ {
299
+ "cell_type": "code",
300
+ "execution_count": 68,
301
+ "id": "ab0ca561",
302
+ "metadata": {},
303
+ "outputs": [
304
+ {
305
+ "name": "stderr",
306
+ "output_type": "stream",
307
+ "text": [
308
+ "c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\scipy\\stats\\_stats_py.py:8022: RuntimeWarning: divide by zero encountered in divide\n",
309
+ " terms = (f_obs_float - f_exp)**2 / f_exp\n",
310
+ "c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\scipy\\stats\\_stats_py.py:8022: RuntimeWarning: divide by zero encountered in divide\n",
311
+ " terms = (f_obs_float - f_exp)**2 / f_exp\n",
312
+ "c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\scipy\\stats\\_stats_py.py:8022: RuntimeWarning: divide by zero encountered in divide\n",
313
+ " terms = (f_obs_float - f_exp)**2 / f_exp\n",
314
+ "c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\scipy\\stats\\_stats_py.py:8022: RuntimeWarning: divide by zero encountered in divide\n",
315
+ " terms = (f_obs_float - f_exp)**2 / f_exp\n",
316
+ "c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\scipy\\stats\\_stats_py.py:8022: RuntimeWarning: divide by zero encountered in divide\n",
317
+ " terms = (f_obs_float - f_exp)**2 / f_exp\n",
318
+ "c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\scipy\\stats\\_stats_py.py:8022: RuntimeWarning: divide by zero encountered in divide\n",
319
+ " terms = (f_obs_float - f_exp)**2 / f_exp\n"
320
+ ]
321
+ },
322
+ {
323
+ "name": "stdout",
324
+ "output_type": "stream",
325
+ "text": [
326
+ "(275, 2)\n"
327
+ ]
328
+ }
329
+ ],
330
+ "source": [
331
+ "drift_results = []\n",
332
+ "\n",
333
+ "for col in non_constant_cols:\n",
334
+ " report = Report(metrics = [ColumnDriftMetric(column_name = col)])\n",
335
+ "\n",
336
+ " try:\n",
337
+ " report.run(reference_data = df_reference[[col]], current_data = df_production[[col]])\n",
338
+ "\n",
339
+ " result = report.as_dict()\n",
340
+ " drift_detected = result[\"metrics\"][0][\"result\"][\"drift_detected\"]\n",
341
+ "\n",
342
+ " drift_results.append({\n",
343
+ " \"colonne\": col,\n",
344
+ " \"drift_detected\": drift_detected})\n",
345
+ "\n",
346
+ " except Exception as e:\n",
347
+ " drift_results.append({\"colonne\": col, \"drift_detected\": \"ERREUR\", \"exception\": str(e)})\n",
348
+ "\n",
349
+ "df_drift = pd.DataFrame(drift_results)\n",
350
+ "print(df_drift.shape)\n",
351
+ "report_drift = report\n"
352
+ ]
353
+ },
354
+ {
355
+ "cell_type": "markdown",
356
+ "id": "8ce86333",
357
+ "metadata": {},
358
+ "source": [
359
+ "### Résumé"
360
+ ]
361
+ },
362
+ {
363
+ "cell_type": "code",
364
+ "execution_count": 69,
365
+ "id": "d80c7637",
366
+ "metadata": {},
367
+ "outputs": [
368
+ {
369
+ "name": "stderr",
370
+ "output_type": "stream",
371
+ "text": [
372
+ "c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\scipy\\stats\\_stats_py.py:8022: RuntimeWarning: divide by zero encountered in divide\n",
373
+ " terms = (f_obs_float - f_exp)**2 / f_exp\n",
374
+ "c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\scipy\\stats\\_stats_py.py:8022: RuntimeWarning: divide by zero encountered in divide\n",
375
+ " terms = (f_obs_float - f_exp)**2 / f_exp\n",
376
+ "c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\scipy\\stats\\_stats_py.py:8022: RuntimeWarning: divide by zero encountered in divide\n",
377
+ " terms = (f_obs_float - f_exp)**2 / f_exp\n",
378
+ "c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\scipy\\stats\\_stats_py.py:8022: RuntimeWarning: divide by zero encountered in divide\n",
379
+ " terms = (f_obs_float - f_exp)**2 / f_exp\n",
380
+ "c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\scipy\\stats\\_stats_py.py:8022: RuntimeWarning: divide by zero encountered in divide\n",
381
+ " terms = (f_obs_float - f_exp)**2 / f_exp\n",
382
+ "c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\scipy\\stats\\_stats_py.py:8022: RuntimeWarning: divide by zero encountered in divide\n",
383
+ " terms = (f_obs_float - f_exp)**2 / f_exp\n"
384
+ ]
385
+ }
386
+ ],
387
+ "source": [
388
+ "from evidently.metrics import DatasetDriftMetric\n",
389
+ "report = Report(metrics=[DatasetDriftMetric()])\n",
390
+ "report.run(reference_data=df_reference, current_data=df_production)\n",
391
+ "\n",
392
+ "res = report.as_dict()"
393
+ ]
394
+ },
395
+ {
396
+ "cell_type": "code",
397
+ "execution_count": 70,
398
+ "id": "9da53766",
399
+ "metadata": {},
400
+ "outputs": [
401
+ {
402
+ "name": "stdout",
403
+ "output_type": "stream",
404
+ "text": [
405
+ "Colonnes analysées : 275\n",
406
+ "Colonnes en dérive : 18\n",
407
+ "Taux de dérive : 6.5%\n"
408
+ ]
409
+ }
410
+ ],
411
+ "source": [
412
+ "dataset_drift = next(\n",
413
+ " m for m in res[\"metrics\"]\n",
414
+ " if m[\"metric\"] == \"DatasetDriftMetric\")\n",
415
+ "\n",
416
+ "drift_res = dataset_drift[\"result\"]\n",
417
+ "\n",
418
+ "nb_cols = drift_res[\"number_of_columns\"]\n",
419
+ "nb_drift = drift_res[\"number_of_drifted_columns\"]\n",
420
+ "taux = nb_drift / nb_cols\n",
421
+ "\n",
422
+ "print(\"Colonnes analysées :\", nb_cols)\n",
423
+ "print(\"Colonnes en dérive :\", nb_drift)\n",
424
+ "print(f\"Taux de dérive : {taux:.1%}\")\n"
425
+ ]
426
+ },
427
+ {
428
+ "cell_type": "code",
429
+ "execution_count": 71,
430
+ "id": "28838cdc",
431
+ "metadata": {},
432
+ "outputs": [
433
+ {
434
+ "data": {
435
+ "text/html": [
436
+ "<div>\n",
437
+ "<style scoped>\n",
438
+ " .dataframe tbody tr th:only-of-type {\n",
439
+ " vertical-align: middle;\n",
440
+ " }\n",
441
+ "\n",
442
+ " .dataframe tbody tr th {\n",
443
+ " vertical-align: top;\n",
444
+ " }\n",
445
+ "\n",
446
+ " .dataframe thead th {\n",
447
+ " text-align: right;\n",
448
+ " }\n",
449
+ "</style>\n",
450
+ "<table border=\"1\" class=\"dataframe\">\n",
451
+ " <thead>\n",
452
+ " <tr style=\"text-align: right;\">\n",
453
+ " <th></th>\n",
454
+ " <th>colonne</th>\n",
455
+ " <th>drift_detected</th>\n",
456
+ " </tr>\n",
457
+ " </thead>\n",
458
+ " <tbody>\n",
459
+ " <tr>\n",
460
+ " <th>6</th>\n",
461
+ " <td>num__PREV_PRODUCT_COMBINATION_POS others witho...</td>\n",
462
+ " <td>True</td>\n",
463
+ " </tr>\n",
464
+ " <tr>\n",
465
+ " <th>57</th>\n",
466
+ " <td>num__BUREAU_STATUS_4</td>\n",
467
+ " <td>True</td>\n",
468
+ " </tr>\n",
469
+ " <tr>\n",
470
+ " <th>60</th>\n",
471
+ " <td>num__PREV_NAME_CASH_LOAN_PURPOSE_Buying a holi...</td>\n",
472
+ " <td>True</td>\n",
473
+ " </tr>\n",
474
+ " <tr>\n",
475
+ " <th>66</th>\n",
476
+ " <td>num__PREV_NAME_GOODS_CATEGORY_Vehicles</td>\n",
477
+ " <td>True</td>\n",
478
+ " </tr>\n",
479
+ " <tr>\n",
480
+ " <th>84</th>\n",
481
+ " <td>num__PREV_NAME_CASH_LOAN_PURPOSE_Medicine</td>\n",
482
+ " <td>True</td>\n",
483
+ " </tr>\n",
484
+ " <tr>\n",
485
+ " <th>86</th>\n",
486
+ " <td>num__PREV_NAME_CASH_LOAN_PURPOSE_Wedding / gif...</td>\n",
487
+ " <td>True</td>\n",
488
+ " </tr>\n",
489
+ " <tr>\n",
490
+ " <th>89</th>\n",
491
+ " <td>num__DAYS_REGISTRATION</td>\n",
492
+ " <td>True</td>\n",
493
+ " </tr>\n",
494
+ " <tr>\n",
495
+ " <th>94</th>\n",
496
+ " <td>num__PREV_NAME_GOODS_CATEGORY_Jewelry</td>\n",
497
+ " <td>True</td>\n",
498
+ " </tr>\n",
499
+ " <tr>\n",
500
+ " <th>123</th>\n",
501
+ " <td>num__PREV_CODE_REJECT_REASON_NUNIQUE</td>\n",
502
+ " <td>True</td>\n",
503
+ " </tr>\n",
504
+ " <tr>\n",
505
+ " <th>133</th>\n",
506
+ " <td>num__PREV_CODE_REJECT_REASON_SCOFR</td>\n",
507
+ " <td>True</td>\n",
508
+ " </tr>\n",
509
+ " <tr>\n",
510
+ " <th>145</th>\n",
511
+ " <td>num__PREV_NAME_CASH_LOAN_PURPOSE_Other</td>\n",
512
+ " <td>True</td>\n",
513
+ " </tr>\n",
514
+ " <tr>\n",
515
+ " <th>146</th>\n",
516
+ " <td>num__PREV_NAME_GOODS_CATEGORY_Homewares</td>\n",
517
+ " <td>True</td>\n",
518
+ " </tr>\n",
519
+ " <tr>\n",
520
+ " <th>148</th>\n",
521
+ " <td>num__PREV_NAME_SELLER_INDUSTRY_Industry</td>\n",
522
+ " <td>True</td>\n",
523
+ " </tr>\n",
524
+ " <tr>\n",
525
+ " <th>150</th>\n",
526
+ " <td>num__PREV_PRODUCT_COMBINATION_POS industry wit...</td>\n",
527
+ " <td>True</td>\n",
528
+ " </tr>\n",
529
+ " <tr>\n",
530
+ " <th>194</th>\n",
531
+ " <td>num__PREV_NAME_TYPE_SUITE_Other_B</td>\n",
532
+ " <td>True</td>\n",
533
+ " </tr>\n",
534
+ " <tr>\n",
535
+ " <th>221</th>\n",
536
+ " <td>card_faible__NAME_EDUCATION_TYPE_Incomplete hi...</td>\n",
537
+ " <td>True</td>\n",
538
+ " </tr>\n",
539
+ " <tr>\n",
540
+ " <th>253</th>\n",
541
+ " <td>card_faible__WALLSMATERIAL_MODE_Wooden</td>\n",
542
+ " <td>True</td>\n",
543
+ " </tr>\n",
544
+ " <tr>\n",
545
+ " <th>259</th>\n",
546
+ " <td>bool__FLAG_WORK_PHONE</td>\n",
547
+ " <td>True</td>\n",
548
+ " </tr>\n",
549
+ " </tbody>\n",
550
+ "</table>\n",
551
+ "</div>"
552
+ ],
553
+ "text/plain": [
554
+ " colonne drift_detected\n",
555
+ "6 num__PREV_PRODUCT_COMBINATION_POS others witho... True\n",
556
+ "57 num__BUREAU_STATUS_4 True\n",
557
+ "60 num__PREV_NAME_CASH_LOAN_PURPOSE_Buying a holi... True\n",
558
+ "66 num__PREV_NAME_GOODS_CATEGORY_Vehicles True\n",
559
+ "84 num__PREV_NAME_CASH_LOAN_PURPOSE_Medicine True\n",
560
+ "86 num__PREV_NAME_CASH_LOAN_PURPOSE_Wedding / gif... True\n",
561
+ "89 num__DAYS_REGISTRATION True\n",
562
+ "94 num__PREV_NAME_GOODS_CATEGORY_Jewelry True\n",
563
+ "123 num__PREV_CODE_REJECT_REASON_NUNIQUE True\n",
564
+ "133 num__PREV_CODE_REJECT_REASON_SCOFR True\n",
565
+ "145 num__PREV_NAME_CASH_LOAN_PURPOSE_Other True\n",
566
+ "146 num__PREV_NAME_GOODS_CATEGORY_Homewares True\n",
567
+ "148 num__PREV_NAME_SELLER_INDUSTRY_Industry True\n",
568
+ "150 num__PREV_PRODUCT_COMBINATION_POS industry wit... True\n",
569
+ "194 num__PREV_NAME_TYPE_SUITE_Other_B True\n",
570
+ "221 card_faible__NAME_EDUCATION_TYPE_Incomplete hi... True\n",
571
+ "253 card_faible__WALLSMATERIAL_MODE_Wooden True\n",
572
+ "259 bool__FLAG_WORK_PHONE True"
573
+ ]
574
+ },
575
+ "execution_count": 71,
576
+ "metadata": {},
577
+ "output_type": "execute_result"
578
+ }
579
+ ],
580
+ "source": [
581
+ "# Colonnes en dérive\n",
582
+ "df_drift[df_drift[\"drift_detected\"] == True]\n"
583
+ ]
584
+ },
585
+ {
586
+ "cell_type": "markdown",
587
+ "id": "45158001",
588
+ "metadata": {},
589
+ "source": [
590
+ "## **Optimisation des performances du modèle**"
591
+ ]
592
+ },
593
+ {
594
+ "cell_type": "markdown",
595
+ "id": "170cd7fe",
596
+ "metadata": {},
597
+ "source": [
598
+ "### Apperçu global"
599
+ ]
600
+ },
601
+ {
602
+ "cell_type": "code",
603
+ "execution_count": 72,
604
+ "id": "f40c42f6",
605
+ "metadata": {},
606
+ "outputs": [
607
+ {
608
+ "data": {
609
+ "text/html": [
610
+ "<div>\n",
611
+ "<style scoped>\n",
612
+ " .dataframe tbody tr th:only-of-type {\n",
613
+ " vertical-align: middle;\n",
614
+ " }\n",
615
+ "\n",
616
+ " .dataframe tbody tr th {\n",
617
+ " vertical-align: top;\n",
618
+ " }\n",
619
+ "\n",
620
+ " .dataframe thead th {\n",
621
+ " text-align: right;\n",
622
+ " }\n",
623
+ "</style>\n",
624
+ "<table border=\"1\" class=\"dataframe\">\n",
625
+ " <thead>\n",
626
+ " <tr style=\"text-align: right;\">\n",
627
+ " <th></th>\n",
628
+ " <th>num__SK_ID_CURR</th>\n",
629
+ " <th>num__BUREAU_SK_ID_BUREAU_max</th>\n",
630
+ " <th>num__POS_SK_DPD_min</th>\n",
631
+ " <th>num__CC_SK_DPD_DEF_max</th>\n",
632
+ " <th>num__PREV_NAME_TYPE_SUITE_Family</th>\n",
633
+ " <th>num__PREV_DAYS_FIRST_DRAWING_sum</th>\n",
634
+ " <th>num__PREV_NAME_GOODS_CATEGORY_Other</th>\n",
635
+ " <th>num__DAYS_LAST_PHONE_CHANGE</th>\n",
636
+ " <th>num__CC_CNT_DRAWINGS_OTHER_CURRENT_mean</th>\n",
637
+ " <th>num__PREV_DAYS_FIRST_DRAWING_max</th>\n",
638
+ " <th>...</th>\n",
639
+ " <th>ram_percent</th>\n",
640
+ " <th>system_load</th>\n",
641
+ " <th>num_threads</th>\n",
642
+ " <th>method</th>\n",
643
+ " <th>status</th>\n",
644
+ " <th>error_message</th>\n",
645
+ " <th>latency_ms</th>\n",
646
+ " <th>request_size_bytes</th>\n",
647
+ " <th>response_size_bytes</th>\n",
648
+ " <th>batch_size_y</th>\n",
649
+ " </tr>\n",
650
+ " </thead>\n",
651
+ " <tbody>\n",
652
+ " <tr>\n",
653
+ " <th>0</th>\n",
654
+ " <td>-0.302429</td>\n",
655
+ " <td>0.326039</td>\n",
656
+ " <td>0.249338</td>\n",
657
+ " <td>NaN</td>\n",
658
+ " <td>-0.535936</td>\n",
659
+ " <td>-0.300165</td>\n",
660
+ " <td>0.23674</td>\n",
661
+ " <td>-0.987792</td>\n",
662
+ " <td>NaN</td>\n",
663
+ " <td>0.246419</td>\n",
664
+ " <td>...</td>\n",
665
+ " <td>78.3</td>\n",
666
+ " <td>0.0</td>\n",
667
+ " <td>21</td>\n",
668
+ " <td>POST</td>\n",
669
+ " <td>success</td>\n",
670
+ " <td>None</td>\n",
671
+ " <td>383.741379</td>\n",
672
+ " <td>12798.0</td>\n",
673
+ " <td>0.0</td>\n",
674
+ " <td>NaN</td>\n",
675
+ " </tr>\n",
676
+ " <tr>\n",
677
+ " <th>1</th>\n",
678
+ " <td>-0.147132</td>\n",
679
+ " <td>0.553947</td>\n",
680
+ " <td>0.249338</td>\n",
681
+ " <td>NaN</td>\n",
682
+ " <td>-0.535936</td>\n",
683
+ " <td>0.742804</td>\n",
684
+ " <td>0.23674</td>\n",
685
+ " <td>0.895050</td>\n",
686
+ " <td>NaN</td>\n",
687
+ " <td>0.246419</td>\n",
688
+ " <td>...</td>\n",
689
+ " <td>78.3</td>\n",
690
+ " <td>0.0</td>\n",
691
+ " <td>21</td>\n",
692
+ " <td>POST</td>\n",
693
+ " <td>success</td>\n",
694
+ " <td>None</td>\n",
695
+ " <td>102.715015</td>\n",
696
+ " <td>12775.0</td>\n",
697
+ " <td>0.0</td>\n",
698
+ " <td>NaN</td>\n",
699
+ " </tr>\n",
700
+ " <tr>\n",
701
+ " <th>2</th>\n",
702
+ " <td>-0.429638</td>\n",
703
+ " <td>0.448635</td>\n",
704
+ " <td>0.249338</td>\n",
705
+ " <td>NaN</td>\n",
706
+ " <td>0.494736</td>\n",
707
+ " <td>-0.821649</td>\n",
708
+ " <td>0.23674</td>\n",
709
+ " <td>0.962033</td>\n",
710
+ " <td>NaN</td>\n",
711
+ " <td>0.246419</td>\n",
712
+ " <td>...</td>\n",
713
+ " <td>78.4</td>\n",
714
+ " <td>0.0</td>\n",
715
+ " <td>21</td>\n",
716
+ " <td>POST</td>\n",
717
+ " <td>success</td>\n",
718
+ " <td>None</td>\n",
719
+ " <td>67.815304</td>\n",
720
+ " <td>12875.0</td>\n",
721
+ " <td>0.0</td>\n",
722
+ " <td>NaN</td>\n",
723
+ " </tr>\n",
724
+ " <tr>\n",
725
+ " <th>3</th>\n",
726
+ " <td>0.246223</td>\n",
727
+ " <td>0.491943</td>\n",
728
+ " <td>0.249338</td>\n",
729
+ " <td>0.691535</td>\n",
730
+ " <td>2.556081</td>\n",
731
+ " <td>4.392488</td>\n",
732
+ " <td>0.23674</td>\n",
733
+ " <td>-2.192274</td>\n",
734
+ " <td>1.997573</td>\n",
735
+ " <td>0.246419</td>\n",
736
+ " <td>...</td>\n",
737
+ " <td>78.4</td>\n",
738
+ " <td>0.0</td>\n",
739
+ " <td>21</td>\n",
740
+ " <td>POST</td>\n",
741
+ " <td>success</td>\n",
742
+ " <td>None</td>\n",
743
+ " <td>89.750528</td>\n",
744
+ " <td>12927.0</td>\n",
745
+ " <td>0.0</td>\n",
746
+ " <td>NaN</td>\n",
747
+ " </tr>\n",
748
+ " <tr>\n",
749
+ " <th>4</th>\n",
750
+ " <td>-1.169600</td>\n",
751
+ " <td>0.699197</td>\n",
752
+ " <td>0.249338</td>\n",
753
+ " <td>NaN</td>\n",
754
+ " <td>-0.535936</td>\n",
755
+ " <td>-0.821649</td>\n",
756
+ " <td>0.23674</td>\n",
757
+ " <td>0.744033</td>\n",
758
+ " <td>NaN</td>\n",
759
+ " <td>0.246419</td>\n",
760
+ " <td>...</td>\n",
761
+ " <td>78.3</td>\n",
762
+ " <td>0.0</td>\n",
763
+ " <td>21</td>\n",
764
+ " <td>POST</td>\n",
765
+ " <td>success</td>\n",
766
+ " <td>None</td>\n",
767
+ " <td>68.776608</td>\n",
768
+ " <td>12836.0</td>\n",
769
+ " <td>0.0</td>\n",
770
+ " <td>NaN</td>\n",
771
+ " </tr>\n",
772
+ " </tbody>\n",
773
+ "</table>\n",
774
+ "<p>5 rows × 406 columns</p>\n",
775
+ "</div>"
776
+ ],
777
+ "text/plain": [
778
+ " num__SK_ID_CURR num__BUREAU_SK_ID_BUREAU_max num__POS_SK_DPD_min \\\n",
779
+ "0 -0.302429 0.326039 0.249338 \n",
780
+ "1 -0.147132 0.553947 0.249338 \n",
781
+ "2 -0.429638 0.448635 0.249338 \n",
782
+ "3 0.246223 0.491943 0.249338 \n",
783
+ "4 -1.169600 0.699197 0.249338 \n",
784
+ "\n",
785
+ " num__CC_SK_DPD_DEF_max num__PREV_NAME_TYPE_SUITE_Family \\\n",
786
+ "0 NaN -0.535936 \n",
787
+ "1 NaN -0.535936 \n",
788
+ "2 NaN 0.494736 \n",
789
+ "3 0.691535 2.556081 \n",
790
+ "4 NaN -0.535936 \n",
791
+ "\n",
792
+ " num__PREV_DAYS_FIRST_DRAWING_sum num__PREV_NAME_GOODS_CATEGORY_Other \\\n",
793
+ "0 -0.300165 0.23674 \n",
794
+ "1 0.742804 0.23674 \n",
795
+ "2 -0.821649 0.23674 \n",
796
+ "3 4.392488 0.23674 \n",
797
+ "4 -0.821649 0.23674 \n",
798
+ "\n",
799
+ " num__DAYS_LAST_PHONE_CHANGE num__CC_CNT_DRAWINGS_OTHER_CURRENT_mean \\\n",
800
+ "0 -0.987792 NaN \n",
801
+ "1 0.895050 NaN \n",
802
+ "2 0.962033 NaN \n",
803
+ "3 -2.192274 1.997573 \n",
804
+ "4 0.744033 NaN \n",
805
+ "\n",
806
+ " num__PREV_DAYS_FIRST_DRAWING_max ... ram_percent system_load \\\n",
807
+ "0 0.246419 ... 78.3 0.0 \n",
808
+ "1 0.246419 ... 78.3 0.0 \n",
809
+ "2 0.246419 ... 78.4 0.0 \n",
810
+ "3 0.246419 ... 78.4 0.0 \n",
811
+ "4 0.246419 ... 78.3 0.0 \n",
812
+ "\n",
813
+ " num_threads method status error_message latency_ms \\\n",
814
+ "0 21 POST success None 383.741379 \n",
815
+ "1 21 POST success None 102.715015 \n",
816
+ "2 21 POST success None 67.815304 \n",
817
+ "3 21 POST success None 89.750528 \n",
818
+ "4 21 POST success None 68.776608 \n",
819
+ "\n",
820
+ " request_size_bytes response_size_bytes batch_size_y \n",
821
+ "0 12798.0 0.0 NaN \n",
822
+ "1 12775.0 0.0 NaN \n",
823
+ "2 12875.0 0.0 NaN \n",
824
+ "3 12927.0 0.0 NaN \n",
825
+ "4 12836.0 0.0 NaN \n",
826
+ "\n",
827
+ "[5 rows x 406 columns]"
828
+ ]
829
+ },
830
+ "execution_count": 72,
831
+ "metadata": {},
832
+ "output_type": "execute_result"
833
+ }
834
+ ],
835
+ "source": [
836
+ "df_production_raw.head()"
837
+ ]
838
+ },
839
+ {
840
+ "cell_type": "code",
841
+ "execution_count": 73,
842
+ "id": "29eeb703",
843
+ "metadata": {},
844
+ "outputs": [
845
+ {
846
+ "data": {
847
+ "text/plain": [
848
+ "0 48.473900\n",
849
+ "1 53.282800\n",
850
+ "2 22.520600\n",
851
+ "3 39.389800\n",
852
+ "4 23.058600\n",
853
+ " ... \n",
854
+ "208 48.540900\n",
855
+ "209 45.094800\n",
856
+ "210 45.515200\n",
857
+ "211 46.950299\n",
858
+ "212 52.126600\n",
859
+ "Name: inference_ms_x, Length: 213, dtype: float64"
860
+ ]
861
+ },
862
+ "execution_count": 73,
863
+ "metadata": {},
864
+ "output_type": "execute_result"
865
+ }
866
+ ],
867
+ "source": [
868
+ "# Statistiques inférence\n",
869
+ "df_production_raw['inference_ms_x']"
870
+ ]
871
+ },
872
+ {
873
+ "cell_type": "code",
874
+ "execution_count": 74,
875
+ "id": "e0f67650",
876
+ "metadata": {},
877
+ "outputs": [
878
+ {
879
+ "data": {
880
+ "text/plain": [
881
+ "count 213.000000\n",
882
+ "mean 36.709429\n",
883
+ "std 15.020234\n",
884
+ "min 21.098300\n",
885
+ "25% 24.290100\n",
886
+ "50% 30.452900\n",
887
+ "75% 46.725800\n",
888
+ "max 113.723900\n",
889
+ "Name: inference_ms_x, dtype: float64"
890
+ ]
891
+ },
892
+ "execution_count": 74,
893
+ "metadata": {},
894
+ "output_type": "execute_result"
895
+ }
896
+ ],
897
+ "source": [
898
+ "df_production_raw['inference_ms_x'].describe()"
899
+ ]
900
+ },
901
+ {
902
+ "cell_type": "code",
903
+ "execution_count": 75,
904
+ "id": "2d63c4f6",
905
+ "metadata": {},
906
+ "outputs": [
907
+ {
908
+ "data": {
909
+ "text/plain": [
910
+ "0 383.741379\n",
911
+ "1 102.715015\n",
912
+ "2 67.815304\n",
913
+ "3 89.750528\n",
914
+ "4 68.776608\n",
915
+ " ... \n",
916
+ "208 307.635784\n",
917
+ "209 315.336943\n",
918
+ "210 302.381754\n",
919
+ "211 309.991360\n",
920
+ "212 237.794876\n",
921
+ "Name: latency_ms, Length: 213, dtype: float64"
922
+ ]
923
+ },
924
+ "execution_count": 75,
925
+ "metadata": {},
926
+ "output_type": "execute_result"
927
+ }
928
+ ],
929
+ "source": [
930
+ "# Statistiques latence\n",
931
+ "df_production_raw[\"latency_ms\"]"
932
+ ]
933
+ },
934
+ {
935
+ "cell_type": "code",
936
+ "execution_count": 76,
937
+ "id": "a16d44c9",
938
+ "metadata": {},
939
+ "outputs": [
940
+ {
941
+ "data": {
942
+ "text/plain": [
943
+ "count 213.000000\n",
944
+ "mean 104.265481\n",
945
+ "std 90.755837\n",
946
+ "min 58.841944\n",
947
+ "25% 70.789099\n",
948
+ "50% 78.964949\n",
949
+ "75% 96.737385\n",
950
+ "max 1024.606943\n",
951
+ "Name: latency_ms, dtype: float64"
952
+ ]
953
+ },
954
+ "execution_count": 76,
955
+ "metadata": {},
956
+ "output_type": "execute_result"
957
+ }
958
+ ],
959
+ "source": [
960
+ "df_production_raw[\"latency_ms\"].describe()"
961
+ ]
962
+ },
963
+ {
964
+ "cell_type": "code",
965
+ "execution_count": 77,
966
+ "id": "46a770de",
967
+ "metadata": {},
968
+ "outputs": [
969
+ {
970
+ "data": {
971
+ "text/plain": [
972
+ "0 0.074383\n",
973
+ "1 0.670045\n",
974
+ "2 0.092590\n",
975
+ "3 0.151949\n",
976
+ "4 0.043955\n",
977
+ " ... \n",
978
+ "208 NaN\n",
979
+ "209 NaN\n",
980
+ "210 NaN\n",
981
+ "211 NaN\n",
982
+ "212 0.162290\n",
983
+ "Name: score_x, Length: 213, dtype: float64"
984
+ ]
985
+ },
986
+ "execution_count": 77,
987
+ "metadata": {},
988
+ "output_type": "execute_result"
989
+ }
990
+ ],
991
+ "source": [
992
+ "# Statistiques score\n",
993
+ "df_production_raw[\"score_x\"]"
994
+ ]
995
+ },
996
+ {
997
+ "cell_type": "code",
998
+ "execution_count": 78,
999
+ "id": "cc4e442a",
1000
+ "metadata": {},
1001
+ "outputs": [
1002
+ {
1003
+ "data": {
1004
+ "text/plain": [
1005
+ "count 201.000000\n",
1006
+ "mean 0.213696\n",
1007
+ "std 0.161163\n",
1008
+ "min 0.021356\n",
1009
+ "25% 0.084765\n",
1010
+ "50% 0.190217\n",
1011
+ "75% 0.285706\n",
1012
+ "max 0.793830\n",
1013
+ "Name: score_x, dtype: float64"
1014
+ ]
1015
+ },
1016
+ "execution_count": 78,
1017
+ "metadata": {},
1018
+ "output_type": "execute_result"
1019
+ }
1020
+ ],
1021
+ "source": [
1022
+ "df_production_raw[\"score_x\"].describe()"
1023
+ ]
1024
+ },
1025
+ {
1026
+ "cell_type": "code",
1027
+ "execution_count": 79,
1028
+ "id": "37fc2c20",
1029
+ "metadata": {},
1030
+ "outputs": [
1031
+ {
1032
+ "data": {
1033
+ "text/plain": [
1034
+ "decision_x\n",
1035
+ "ACCORDÉ 184\n",
1036
+ "REFUSÉ 17\n",
1037
+ "Name: count, dtype: int64"
1038
+ ]
1039
+ },
1040
+ "execution_count": 79,
1041
+ "metadata": {},
1042
+ "output_type": "execute_result"
1043
+ }
1044
+ ],
1045
+ "source": [
1046
+ "df_production_raw[\"decision_x\"].value_counts()"
1047
+ ]
1048
+ },
1049
+ {
1050
+ "cell_type": "markdown",
1051
+ "id": "281fe7aa",
1052
+ "metadata": {},
1053
+ "source": [
1054
+ "### Statistiques globales sur les performances API"
1055
+ ]
1056
+ },
1057
+ {
1058
+ "cell_type": "markdown",
1059
+ "id": "0217db8c",
1060
+ "metadata": {},
1061
+ "source": [
1062
+ "Les métriques de production montrent que la latence moyenne de l’API est de *104 ms*, avec un p95 à *300 ms* et quelques pics à 1 seconde.\n",
1063
+ "\n",
1064
+ "Le CPU reste faible *(24 %)*, mais la RAM est élevée *(74 %)*, ce qui confirme que l’API n’est pas limitée par le modèle mais par le ***preprocessing***.\n",
1065
+ "\n",
1066
+ "Le temps d’inférence mesuré **(36 ms en moyenne, 65 ms au p95)** correspond essentiellement au preprocessing sklearn, le modèle lui-même étant très rapide **(< 3 ms)**.\n",
1067
+ "\n",
1068
+ "Ces résultats confirment que l’optimisation doit se concentrer sur le preprocessing plutôt que sur le modèle. "
1069
+ ]
1070
+ },
1071
+ {
1072
+ "cell_type": "code",
1073
+ "execution_count": 80,
1074
+ "id": "6aea8f28",
1075
+ "metadata": {},
1076
+ "outputs": [
1077
+ {
1078
+ "name": "stdout",
1079
+ "output_type": "stream",
1080
+ "text": [
1081
+ "latency_mean_p95_max: (104.26548053401177, 300.34413337707514, 1024.6069431304932)\n",
1082
+ "cpu_ram: (24.00985915492958, 74.26103286384976)\n",
1083
+ "infer: (64.89101992920038, 36.70942912341703)\n"
1084
+ ]
1085
+ }
1086
+ ],
1087
+ "source": [
1088
+ "lat_mean = df_production_raw[\"latency_ms\"].mean() # latence moyenne\n",
1089
+ "lat_p95 = df_production_raw[\"latency_ms\"].quantile(0.95) # latence au 95ème percentile\n",
1090
+ "lat_max = df_production_raw[\"latency_ms\"].max() # latence maximale observée\n",
1091
+ "\n",
1092
+ "cpu_mean = df_production_raw[\"cpu_percent\"].mean()\n",
1093
+ "ram_mean = df_production_raw[\"ram_percent\"].mean()\n",
1094
+ "\n",
1095
+ "infer_mean = df_production_raw[\"inference_ms_x\"].mean() # temps moyen passé dans predict_proba()\n",
1096
+ "infer_p95 = df_production_raw[\"inference_ms_x\"].quantile(0.95) # temps au 95ème percentile\n",
1097
+ "\n",
1098
+ "print(f\"latency_mean_p95_max: {lat_mean, lat_p95, lat_max}\")\n",
1099
+ "print(f\"cpu_ram: {cpu_mean, ram_mean}\")\n",
1100
+ "print(f\"infer: {infer_p95, infer_mean}\")"
1101
+ ]
1102
+ },
1103
+ {
1104
+ "cell_type": "markdown",
1105
+ "id": "3050b4f2",
1106
+ "metadata": {},
1107
+ "source": [
1108
+ "### Recherche des goulots d'étranglement - **cProfile**"
1109
+ ]
1110
+ },
1111
+ {
1112
+ "cell_type": "code",
1113
+ "execution_count": 81,
1114
+ "id": "26f53c38",
1115
+ "metadata": {},
1116
+ "outputs": [
1117
+ {
1118
+ "name": "stdout",
1119
+ "output_type": "stream",
1120
+ "text": [
1121
+ "Sun Jun 14 01:44:09 2026 profiling.prof\n",
1122
+ "\n",
1123
+ " 4105904 function calls (4085504 primitive calls) in 9.293 seconds\n",
1124
+ "\n",
1125
+ " Ordered by: cumulative time\n",
1126
+ " List reduced from 591 to 18 due to restriction <18>\n",
1127
+ "\n",
1128
+ " ncalls tottime percall cumtime percall filename:lineno(function)\n",
1129
+ " 1 0.000 0.000 9.346 9.346 {built-in method builtins.exec}\n",
1130
+ " 1 0.000 0.000 9.345 9.345 <string>:1(<module>)\n",
1131
+ " 1 0.029 0.029 9.345 9.345 C:\\Users\\Lenovo\\AppData\\Local\\Temp\\ipykernel_6608\\1097060041.py:1(benchmark)\n",
1132
+ " 100 0.003 0.000 9.314 0.093 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\pipeline.py:676(predict_proba)\n",
1133
+ " 500/100 0.035 0.000 8.744 0.087 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\utils\\_set_output.py:293(wrapped)\n",
1134
+ " 100 0.047 0.000 8.708 0.087 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\compose\\_column_transformer.py:946(transform)\n",
1135
+ " 100 0.010 0.000 8.285 0.083 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\compose\\_column_transformer.py:751(_call_func_on_transformers)\n",
1136
+ " 100 0.001 0.000 7.349 0.073 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\utils\\parallel.py:44(__call__)\n",
1137
+ " 100 0.005 0.000 7.347 0.073 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\joblib\\parallel.py:1969(__call__)\n",
1138
+ " 600 0.008 0.000 7.334 0.012 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\joblib\\parallel.py:1888(_get_sequential_output)\n",
1139
+ " 400 0.007 0.000 7.322 0.018 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\utils\\parallel.py:115(__call__)\n",
1140
+ " 400 0.004 0.000 7.280 0.018 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\pipeline.py:1261(_transform_one)\n",
1141
+ " 200 0.076 0.000 4.892 0.024 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\preprocessing\\_encoders.py:185(_transform)\n",
1142
+ " 100 0.018 0.000 4.126 0.041 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\preprocessing\\_encoders.py:984(transform)\n",
1143
+ " 1700 0.189 0.000 3.029 0.002 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\utils\\validation.py:718(check_array)\n",
1144
+ " 1600 0.134 0.000 2.413 0.002 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\utils\\_encode.py:236(_check_unknown)\n",
1145
+ " 100 0.050 0.000 2.260 0.023 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\preprocessing\\_data.py:1025(transform)\n",
1146
+ " 100 0.003 0.000 2.205 0.022 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\base.py:537(_validate_data)\n",
1147
+ "\n",
1148
+ "\n"
1149
+ ]
1150
+ },
1151
+ {
1152
+ "data": {
1153
+ "text/plain": [
1154
+ "<pstats.Stats at 0x28333231810>"
1155
+ ]
1156
+ },
1157
+ "execution_count": 81,
1158
+ "metadata": {},
1159
+ "output_type": "execute_result"
1160
+ }
1161
+ ],
1162
+ "source": [
1163
+ "def benchmark():\n",
1164
+ " for _ in range(100):\n",
1165
+ " pipe.predict_proba(df_reference_raw)\n",
1166
+ "\n",
1167
+ "cProfile.run(\n",
1168
+ " \"benchmark()\",\n",
1169
+ " \"profiling.prof\")\n",
1170
+ "\n",
1171
+ "stats = pstats.Stats(\"profiling.prof\")\n",
1172
+ "stats.sort_stats(\"cumtime\")\n",
1173
+ "stats.print_stats(18)"
1174
+ ]
1175
+ },
1176
+ {
1177
+ "cell_type": "markdown",
1178
+ "id": "03fc7e60",
1179
+ "metadata": {},
1180
+ "source": [
1181
+ "Résultat profiling sur l'ensemble du dataset.\n",
1182
+ "Sat Jun 13 23:37:16 2026 profiling.prof\n",
1183
+ "\n",
1184
+ " 150875804 function calls (150855404 primitive calls) in 170.527 seconds\n",
1185
+ "\n",
1186
+ " Ordered by: cumulative time\n",
1187
+ " List reduced from 593 to 18 due to restriction <18>\n",
1188
+ "\n",
1189
+ " ncalls tottime percall cumtime percall filename:lineno(function)\n",
1190
+ " 1 0.000 0.000 170.568 170.568 {built-in method builtins.exec}\n",
1191
+ " 1 0.000 0.000 170.568 170.568 <string>:1(<module>)\n",
1192
+ " 1 2.378 2.378 170.568 170.568 C:\\Users\\Lenovo\\AppData\\Local\\Temp\\ipykernel_6608\\4137855541.py:4(benchmark)\n",
1193
+ " 100 0.002 0.000 168.186 1.682 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\pipeline.py:676(predict_proba)\n",
1194
+ " 500/100 1.023 0.002 145.599 1.456 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\utils\\_set_output.py:293(wrapped)\n",
1195
+ " 100 1.367 0.014 144.604 1.446 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\compose\\_column_transformer.py:946(transform)\n",
1196
+ " 100 0.009 0.000 136.908 1.369 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\compose\\_column_transformer.py:751(_call_func_on_transformers)\n",
1197
+ " 100 0.001 0.000 129.304 1.293 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\utils\\parallel.py:44(__call__)\n",
1198
+ " 100 0.002 0.000 129.303 1.293 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\joblib\\parallel.py:1969(__call__)\n",
1199
+ " 600 0.005 0.000 129.296 0.215 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\joblib\\parallel.py:1888(_get_sequential_output)\n",
1200
+ " 400 0.004 0.000 129.288 0.323 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\utils\\parallel.py:115(__call__)\n",
1201
+ " 400 0.003 0.000 129.261 0.323 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\pipeline.py:1261(_transform_one)\n",
1202
+ " 200 0.723 0.004 114.522 0.573 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\preprocessing\\_encoders.py:185(_transform)\n",
1203
+ " 100 0.360 0.004 99.135 0.991 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\preprocessing\\_encoders.py:984(transform)\n",
1204
+ " 1600 2.995 0.002 92.976 0.058 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\utils\\_encode.py:236(_check_unknown)\n",
1205
+ " 3200 0.187 0.000 66.984 0.021 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\utils\\_encode.py:108(_extract_missing)\n",
1206
+ " 3200 7.114 0.002 66.791 0.021 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\utils\\_encode.py:124(<setcomp>)\n",
1207
+ " 11946300 15.667 0.000 59.734 0.000 c:\\Users\\Lenovo\\anaconda3\\envs\\mlops\\Lib\\site-packages\\sklearn\\utils\\__init__.py:1151(is_scalar_nan)"
1208
+ ]
1209
+ },
1210
+ {
1211
+ "cell_type": "markdown",
1212
+ "id": "c2c66110",
1213
+ "metadata": {},
1214
+ "source": [
1215
+ "Le profiling sur l'ensemble du dataset (plus de 40000 lignes) montre que la latence du pipeline est dominée par le **preprocessing (85 % du temps)**, en particulier par *OneHotEncoder et ses vérifications internes (_check_unknown, is_scalar_nan)*:\n",
1216
+ "- `ColumnTransformer.transform` <> 144.6 s cumulés\n",
1217
+ "- `OneHotEncoder._transform` <> 114.5 s ; représente **67%** du temps total (170.6 ms) - très coûteux en unitaire\n",
1218
+ "- `OneHotEncoder.transform` <> 99.1 s\n",
1219
+ "- `_check_unknown` <> 92.9 s\n",
1220
+ "- `is_scalar_nan` <> 59.7 s\n",
1221
+ "\n",
1222
+ "Le profiling sur un échantilon (500 lignes) pour des besoins GiHub montre:\n",
1223
+ "- un coût total réduit (9 s au lieu de 170 s)\n",
1224
+ "- des fonctions qui disparaissent car moins de lignes\n",
1225
+ "- un comportement plus “léger”\n",
1226
+ "- un pipeline qui reste coûteux mais moins extrême\n",
1227
+ "Néanmoins, la structure du coût reste la même (preprocessing dominant), mais :\n",
1228
+ "- les appels à `_check_unknown` et `is_scalar_nan` chutent fortement,\n",
1229
+ "- les fonctions liées aux valeurs rares disparaissent du top 20,\n",
1230
+ "- le coût absolu est beaucoup plus faible.\n",
1231
+ "\n",
1232
+ "Les deux profilings sont complémentaires :\n",
1233
+ "- le profiling complet montre le comportement réel du pipeline en production,\n",
1234
+ "- le profiling réduit montre le comportement dans un environnement GitHub/CI.\n",
1235
+ "\n",
1236
+ "Ils démontrent ensemble que :\n",
1237
+ "- **le modèle est très rapide**, \n",
1238
+ "- **le preprocessing est le goulot d’étranglement**, \n",
1239
+ "- **le coût dépend fortement de la taille du dataset**, \n",
1240
+ "- **le batch est indispensable pour réduire la latence**."
1241
+ ]
1242
+ },
1243
+ {
1244
+ "cell_type": "markdown",
1245
+ "id": "2b5587db",
1246
+ "metadata": {},
1247
+ "source": [
1248
+ "### Préprocessing vs modèle\n",
1249
+ "Le modèle lui‑même est très rapide *(< 3 ms)*, mais le preprocessing coûte *23 ms par ligne*, ce qui explique les latences élevées en appels unitaires."
1250
+ ]
1251
+ },
1252
+ {
1253
+ "cell_type": "code",
1254
+ "execution_count": 82,
1255
+ "id": "b313e60b",
1256
+ "metadata": {},
1257
+ "outputs": [
1258
+ {
1259
+ "name": "stdout",
1260
+ "output_type": "stream",
1261
+ "text": [
1262
+ "preprocessing : 19.87539976835251\n",
1263
+ "model : 33.621800132095814\n",
1264
+ "total : 53.49719990044832\n"
1265
+ ]
1266
+ }
1267
+ ],
1268
+ "source": [
1269
+ "try:\n",
1270
+ " df_example = df_reference_raw\n",
1271
+ "except:\n",
1272
+ " df_example = None\n",
1273
+ "\n",
1274
+ "X = df_example.iloc[[0]]\n",
1275
+ "t0 = time.perf_counter()\n",
1276
+ "\n",
1277
+ "X_transformed = pipe[:-1].transform(X)\n",
1278
+ "t1 = time.perf_counter()\n",
1279
+ "\n",
1280
+ "score = pipe[-1].predict_proba(X_transformed)\n",
1281
+ "t2 = time.perf_counter()\n",
1282
+ "\n",
1283
+ "print(\"preprocessing :\", (t1 - t0)*1000)\n",
1284
+ "print(\"model :\", (t2 - t1)*1000)\n",
1285
+ "print(\"total :\", (t2 - t0)*1000)"
1286
+ ]
1287
+ },
1288
+ {
1289
+ "cell_type": "markdown",
1290
+ "id": "873a481d",
1291
+ "metadata": {},
1292
+ "source": [
1293
+ "### Optimisation du preprocessing: unitaire vs batch"
1294
+ ]
1295
+ },
1296
+ {
1297
+ "cell_type": "markdown",
1298
+ "id": "62318faa",
1299
+ "metadata": {},
1300
+ "source": [
1301
+ "Les résultats ci-dessous confirment le profiling:\n",
1302
+ "- 1 ligne > **23 ms** de preprocessing\n",
1303
+ "- 100 lignes en unitaire > **2266 ms**\n",
1304
+ "- 100 lignes en batch > **31 ms**\n",
1305
+ "\n",
1306
+ "Vectorisé, le preprocessing ne s’exécute qu’une seule fois en batch, mais 100 fois en unitaire <> Le batch est sensiblement **70 fois plus rapide que l’unitaire**."
1307
+ ]
1308
+ },
1309
+ {
1310
+ "cell_type": "code",
1311
+ "execution_count": 83,
1312
+ "id": "4041e8d6",
1313
+ "metadata": {},
1314
+ "outputs": [
1315
+ {
1316
+ "name": "stdout",
1317
+ "output_type": "stream",
1318
+ "text": [
1319
+ "100 appels unitaires : 2384.8198000341654 ms\n"
1320
+ ]
1321
+ }
1322
+ ],
1323
+ "source": [
1324
+ "start = time.perf_counter()\n",
1325
+ "\n",
1326
+ "for i in range(100):\n",
1327
+ " pipe.predict_proba(df_example.iloc[[i]])\n",
1328
+ "\n",
1329
+ "end = time.perf_counter()\n",
1330
+ "print(\"100 appels unitaires :\", (end - start) * 1000, \"ms\")"
1331
+ ]
1332
+ },
1333
+ {
1334
+ "cell_type": "code",
1335
+ "execution_count": 84,
1336
+ "id": "ac7fb688",
1337
+ "metadata": {},
1338
+ "outputs": [
1339
+ {
1340
+ "name": "stdout",
1341
+ "output_type": "stream",
1342
+ "text": [
1343
+ "1 batch de 100 lignes : 30.14650009572506 ms\n"
1344
+ ]
1345
+ }
1346
+ ],
1347
+ "source": [
1348
+ "X_batch = df_example.iloc[:100]\n",
1349
+ "\n",
1350
+ "start = time.perf_counter()\n",
1351
+ "pipe.predict_proba(X_batch)\n",
1352
+ "end = time.perf_counter()\n",
1353
+ "\n",
1354
+ "print(\"1 batch de 100 lignes :\", (end - start) * 1000, \"ms\")"
1355
+ ]
1356
+ },
1357
+ {
1358
+ "cell_type": "markdown",
1359
+ "id": "899fdbd4",
1360
+ "metadata": {},
1361
+ "source": [
1362
+ "Le batch permet de vectoriser les transformations et réduit le temps total d’un facteur ×70.\n",
1363
+ "Ces résultats démontrent que l’optimisation doit se concentrer sur le preprocessing plutôt que sur le modèle."
1364
+ ]
1365
+ },
1366
+ {
1367
+ "cell_type": "markdown",
1368
+ "id": "31cbe8ff",
1369
+ "metadata": {},
1370
+ "source": [
1371
+ "# **Conclusion**\n",
1372
+ "\n",
1373
+ "**1. Analyse du data drift**\n",
1374
+ "\n",
1375
+ "Après harmonisation complète des colonnes entre les données de référence et les données de production (conversion des types, gestion des valeurs manquantes, suppression des colonnes constantes, alignement des colonnes communes), nous avons pu analyser le drift sur **278 colonnes**.\n",
1376
+ "\n",
1377
+ "Les résultats montrent :\n",
1378
+ "- **Colonnes testées : 278**\n",
1379
+ "- **Colonnes avec drift détecté : 79**\n",
1380
+ "- **Taux de dérive : 28.4 %**\n",
1381
+ "\n",
1382
+ "Ce taux est significatif : près d’un tiers des variables présentent une distribution différente entre la référence et la production. \n",
1383
+ "Les colonnes les plus touchées concernent principalement :\n",
1384
+ "- les variables dérivées de comportements (durées, montants, ratios),\n",
1385
+ "- certaines variables catégorielles encodées,\n",
1386
+ "- et des variables liées à l’historique de crédit.\n",
1387
+ "\n",
1388
+ "Un tel niveau de drift peut potentiellement impacter la stabilité du modèle, et justifie la mise en place d’un monitoring continu ainsi que d’un mécanisme d’alerte.\n",
1389
+ "\n",
1390
+ "**2. Analyse de la performance du pipeline**\n",
1391
+ "\n",
1392
+ "Les mesures de latence montrent que :\n",
1393
+ "\n",
1394
+ "- **le preprocessing est de loin la partie la plus coûteuse** du pipeline (23 ms par ligne, contre 2.7 ms pour le modèle lui-même),\n",
1395
+ "- **100 appels unitaires** coûtent **2266 ms**, car le preprocessing est répété 100 fois,\n",
1396
+ "- **un batch de 100 lignes** ne coûte que **31 ms**, grâce à la vectorisation des transformations.\n",
1397
+ "\n",
1398
+ "Ces résultats sont confirmés par le profiling, qui montre que :\n",
1399
+ "\n",
1400
+ "- **85 % du temps total** est passé dans `ColumnTransformer.transform`,\n",
1401
+ "- dont **67 % dans OneHotEncoder** et ses vérifications internes (`_check_unknown`, `is_scalar_nan`).\n",
1402
+ "\n",
1403
+ "Le modèle, lui, est très rapide (< 3 ms)."
1404
+ ]
1405
+ }
1406
+ ],
1407
+ "metadata": {
1408
+ "kernelspec": {
1409
+ "display_name": "mlops",
1410
+ "language": "python",
1411
+ "name": "python3"
1412
+ },
1413
+ "language_info": {
1414
+ "codemirror_mode": {
1415
+ "name": "ipython",
1416
+ "version": 3
1417
+ },
1418
+ "file_extension": ".py",
1419
+ "mimetype": "text/x-python",
1420
+ "name": "python",
1421
+ "nbconvert_exporter": "python",
1422
+ "pygments_lexer": "ipython3",
1423
+ "version": "3.11.15"
1424
+ }
1425
+ },
1426
+ "nbformat": 4,
1427
+ "nbformat_minor": 5
1428
+ }
Notesbooks/profiling.prof CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b2ae52e9eb778b0243b90e68c45e9ec181e1f87397683fc89f189821e2488996
3
- size 104535
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:09b3692207cc7a566d4665d22374f715772e658e9a48bfc0244d162e47ade9f9
3
+ size 85998
data/app_test_small.joblib CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d6f74660ca2b267a31b00b5cd35f507d49bea58adfead3328080cfc43806c4e3
3
- size 133099
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8564a44d2b3d2fcbdad3e19019623a4200020a7ed263a38bbb56909136ce9d87
3
+ size 1185131
logs/predictions_log.jsonl CHANGED
@@ -433,3 +433,7 @@
433
  {"request_id": "ca1c07d9-ef18-496f-886c-e160814b7304", "timestamp": 1780969713.6299284, "path": "/predict_batch", "method": "POST", "status": "success", "error_message": null, "latency_ms": 309.99135971069336, "request_size_bytes": 2579512, "response_size_bytes": 0, "cpu_percent": 36.2, "ram_percent": 82.9, "system_load": 0.14, "num_threads": 21}
434
  {"request_id": "5696735a-e30b-445e-a754-c6326ee14adb", "timestamp": 1781070980.6000025, "path": "/docs", "method": "GET", "status": "success", "error_message": null, "latency_ms": 0.9996891021728516, "request_size_bytes": 0, "response_size_bytes": 0, "cpu_percent": 39.5, "ram_percent": 88.6, "system_load": 0.0, "num_threads": 15}
435
  {"request_id": "68da0f50-79ac-4690-9b1d-19e21fe9430d", "timestamp": 1781070981.1768417, "path": "/openapi.json", "method": "GET", "status": "success", "error_message": null, "latency_ms": 159.8834991455078, "request_size_bytes": 0, "response_size_bytes": 0, "cpu_percent": 30.3, "ram_percent": 88.8, "system_load": 0.0, "num_threads": 15}
 
 
 
 
 
433
  {"request_id": "ca1c07d9-ef18-496f-886c-e160814b7304", "timestamp": 1780969713.6299284, "path": "/predict_batch", "method": "POST", "status": "success", "error_message": null, "latency_ms": 309.99135971069336, "request_size_bytes": 2579512, "response_size_bytes": 0, "cpu_percent": 36.2, "ram_percent": 82.9, "system_load": 0.14, "num_threads": 21}
434
  {"request_id": "5696735a-e30b-445e-a754-c6326ee14adb", "timestamp": 1781070980.6000025, "path": "/docs", "method": "GET", "status": "success", "error_message": null, "latency_ms": 0.9996891021728516, "request_size_bytes": 0, "response_size_bytes": 0, "cpu_percent": 39.5, "ram_percent": 88.6, "system_load": 0.0, "num_threads": 15}
435
  {"request_id": "68da0f50-79ac-4690-9b1d-19e21fe9430d", "timestamp": 1781070981.1768417, "path": "/openapi.json", "method": "GET", "status": "success", "error_message": null, "latency_ms": 159.8834991455078, "request_size_bytes": 0, "response_size_bytes": 0, "cpu_percent": 30.3, "ram_percent": 88.8, "system_load": 0.0, "num_threads": 15}
436
+ {"request_id": "d4c36bd2-a5d9-44a0-a097-2ddd3b469956", "timestamp": 1781365503.1845264, "path": "/docs", "method": "GET", "status": "success", "error_message": null, "latency_ms": 0.9987354278564453, "request_size_bytes": 0, "response_size_bytes": 0, "cpu_percent": 79.1, "ram_percent": 77.3, "system_load": 0.0, "num_threads": 15}
437
+ {"request_id": "a243091e-ea7b-44ef-a5c2-dad33417027a", "timestamp": 1781365504.241698, "path": "/openapi.json", "method": "GET", "status": "success", "error_message": null, "latency_ms": 255.31649589538574, "request_size_bytes": 0, "response_size_bytes": 0, "cpu_percent": 80.4, "ram_percent": 77.5, "system_load": 0.0, "num_threads": 15}
438
+ {"request_id": "bf367fa7-4fd2-4600-90d1-1408e389f104", "timestamp": 1781365536.8084311, "inference_ms": 52.12660040706396, "path": "/predict", "inputs": {"num__SK_ID_CURR": 0.6144951075809649, "num__BUREAU_SK_ID_BUREAU_max": NaN, "num__POS_SK_DPD_min": 0.2493379876858778, "num__CC_SK_DPD_DEF_max": NaN, "num__PREV_NAME_TYPE_SUITE_Family": -0.5359363507228432, "num__PREV_DAYS_FIRST_DRAWING_sum": -0.8216487919972778, "num__PREV_NAME_GOODS_CATEGORY_Other": 0.23674011214082938, "num__DAYS_LAST_PHONE_CHANGE": 1.1690723396054634, "num__CC_CNT_DRAWINGS_OTHER_CURRENT_mean": NaN, "num__PREV_DAYS_FIRST_DRAWING_max": 0.24641878222590127, "num__PREV_PRODUCT_COMBINATION_POS others without interest": NaN, "num__PREV_CODE_REJECT_REASON_VERIF": 0.23674011214082938, "num__PREV_NAME_PORTFOLIO_POS": -0.5111520825769634, "num__PREV_NAME_CLIENT_TYPE_New": 0.32855583470205796, "num__OBS_30_CNT_SOCIAL_CIRCLE": -0.6386291553511898, "num__BUREAU_CREDIT_TYPE_Microloan": NaN, "num__ENTRANCES_AVG": NaN, "num__PREV_NAME_GOODS_CATEGORY_Medicine": 0.23674011214082938, "num__PREV_NAME_YIELD_GROUP_low_normal": -0.6621073000902179, "num__BUREAU_CREDIT_TYPE_Car loan": NaN, "num__POS_SK_DPD_DEF_min": 0.2493379876858778, "num__BUREAU_CREDIT_DAY_OVERDUE_mean": NaN, "num__POS_NAME_CONTRACT_STATUS_Signed": -0.28684543050424005, "num__BUREAU_DAYS_ENDDATE_FACT_max": NaN, "num__BUREAU_CREDIT_TYPE_NUNIQUE": NaN, "num__PREV_SELLERPLACE_AREA_sum": -0.5137337734721292, "num__PREV_NAME_GOODS_CATEGORY_Audio/Video": NaN, "num__OWN_CAR_AGE": NaN, "num__LANDAREA_MEDI": NaN, "num__CC_CNT_DRAWINGS_ATM_CURRENT_sum": NaN, "num__PREV_DAYS_TERMINATION_mean": -0.7589897163243742, "num__BUREAU_AMT_CREDIT_SUM_mean": NaN, "num__AMT_REQ_CREDIT_BUREAU_WEEK": NaN, "num__BUREAU_AMT_CREDIT_SUM_OVERDUE_max": NaN, "num__PREV_NAME_CLIENT_TYPE_XNA": 0.23674011214082938, "num__BUREAU_CREDIT_TYPE_Real estate loan": NaN, "num__PREV_NAME_SELLER_INDUSTRY_Jewelry": 0.23674011214082938, "num__PREV_AMT_ANNUITY_min": 3.342432337420309, "num__PREV_WEEKDAY_APPR_PROCESS_START_FRIDAY": 0.33338733924416236, "num__NONLIVINGAREA_AVG": NaN, "num__PREV_WEEKDAY_APPR_PROCESS_START_WEDNESDAY": -0.5343049740365464, "num__BUREAU_DAYS_ENDDATE_FACT_sum": NaN, "num__PREV_NFLAG_INSURED_ON_APPROVAL_sum": -0.6585506950367067, "num__AMT_GOODS_PRICE": 1.0037144156784124, "num__BUREAU_CREDIT_TYPE_Mobile operator loan": NaN, "num__CC_AMT_DRAWINGS_CURRENT_min": NaN, "num__POS_NAME_CONTRACT_STATUS_Canceled": 0.2493379876858778, "num__PREV_CHANNEL_TYPE_Stone": 0.4962486049233096, "num__PREV_NFLAG_LAST_APPL_IN_DAY_max": 0.2367401121408294, "num__PREV_NAME_GOODS_CATEGORY_Consumer Electronics": NaN, "num__INST_PAY_AMT_PAYMENT_min": 3.610582936337547, "num__INST_PAY_NUM_INSTALMENT_VERSION_mean": 0.12649977309898805, "num__BUREAU_STATUS_5": NaN, "num__PREV_PRODUCT_COMBINATION_POS other with interest": NaN, "num__BUREAU_STATUS_1": NaN, "num__BUREAU_AMT_CREDIT_SUM_min": NaN, "num__BUREAU_AMT_CREDIT_SUM_DEBT_sum": NaN, "num__BUREAU_DAYS_CREDIT_ENDDATE_mean": NaN, "num__BUREAU_CNT_CREDIT_PROLONG_sum": NaN, "num__PREV_RATE_INTEREST_PRIMARY_sum": 0.2242465218183754, "num__PREV_NAME_PRODUCT_TYPE_walk-in": NaN, "num__PREV_AMT_DOWN_PAYMENT_sum": -0.6189004337414271, "num__POS_NAME_CONTRACT_STATUS_Completed": -0.4889455224845829, "num__PREV_NAME_TYPE_SUITE_NUNIQUE": -1.2064381961245174, "num__BUREAU_CREDIT_CURRENCY_currency 2": NaN, "num__PREV_NAME_GOODS_CATEGORY_Direct Sales": NaN, "num__PREV_PRODUCT_COMBINATION_Cash X-Sell: middle": NaN, "num__CC_CNT_DRAWINGS_ATM_CURRENT_mean": NaN, "num__PREV_NAME_GOODS_CATEGORY_Sport and Leisure": NaN, "num__PREV_NAME_CASH_LOAN_PURPOSE_Buying a new car": NaN, "num__PREV_RATE_INTEREST_PRIVILEGED_max": NaN, "num__CC_AMT_DRAWINGS_CURRENT_mean": NaN, "num__BUREAU_STATUS_4": NaN, "num__CC_NAME_CONTRACT_STATUS_Signed": NaN, "num__PREV_NAME_SELLER_INDUSTRY_Construction": -0.06521488669355317, "num__PREV_NAME_CASH_LOAN_PURPOSE_Buying a holiday home / land": NaN, "num__PREV_WEEKDAY_APPR_PROCESS_START_MONDAY": -0.5261235216935966, "num__CC_AMT_DRAWINGS_ATM_CURRENT_sum": NaN, "num__BUREAU_AMT_ANNUITY_min": NaN, "num__YEARS_BEGINEXPLUATATION_MEDI": NaN, "num__BUREAU_CREDIT_TYPE_Loan for the purchase of equipment": NaN, "num__CC_UTILIZATION_mean": NaN, "num__PREV_NAME_GOODS_CATEGORY_Vehicles": 0.23674011214082938, "num__DAYS_ID_PUBLISH": 0.4305018416643704, "num__CC_AMT_BALANCE_mean": NaN, "num__BASEMENTAREA_AVG": NaN, "num__PREV_RATE_DOWN_PAYMENT_max": -0.008977241368556479, "num__CC_NAME_CONTRACT_STATUS_Refused": NaN, "num__CC_MONTHS_BALANCE_mean": NaN, "num__CC_NAME_CONTRACT_STATUS_NUNIQUE": NaN, "num__BUREAU_CREDIT_DAY_OVERDUE_sum": NaN, "num__PREV_NAME_CONTRACT_TYPE_XNA": 0.23674011214082938, "num__INST_PAY_PAYMENT_DELAY_sum": 0.7000010824745839, "num__BUREAU_CREDIT_ACTIVE_NUNIQUE": NaN, "num__PREV_NAME_CASH_LOAN_PURPOSE_Buying a garage": NaN, "num__PREV_NAME_CASH_LOAN_PURPOSE_Payments on other loans": NaN, "num__POS_NAME_CONTRACT_STATUS_Approved": 0.17421092622458545, "num__PREV_NAME_GOODS_CATEGORY_Photo / Cinema Equipment": NaN, "num__INST_PAY_DAYS_ENTRY_PAYMENT_min": 0.9882605094547763, "num__CC_UTILIZATION_max": NaN, "num__PREV_PRODUCT_COMBINATION_Card Street": NaN, "num__CC_NAME_CONTRACT_STATUS_Sent proposal": NaN, "num__INST_PAY_AMT_PAYMENT_sum": -0.610943661978752, "num__BUREAU_DAYS_CREDIT_ENDDATE_min": NaN, "num__PREV_NAME_GOODS_CATEGORY_Computers": -0.35599842853649705, "num__PREV_NAME_CASH_LOAN_PURPOSE_Medicine": 0.23674011214082938, "num__POS_NAME_CONTRACT_STATUS_XNA": 0.2493379876858778, "num__PREV_NAME_GOODS_CATEGORY_XNA": -0.7402501666470357, "num__PREV_NAME_CASH_LOAN_PURPOSE_Wedding / gift / holiday": NaN, "num__CC_AMT_PAYMENT_TOTAL_CURRENT_max": NaN, "num__PREV_NAME_SELLER_INDUSTRY_Tourism": 0.23674011214082938, "num__PREV_NAME_CASH_LOAN_PURPOSE_Money for a third person": NaN, "num__PREV_NAME_CASH_LOAN_PURPOSE_Buying a home": NaN, "num__PREV_NAME_CASH_LOAN_PURPOSE_Journey": 0.23674011214082938, "num__DAYS_REGISTRATION": 0.7009653238320351, "num__INST_PAY_PAYMENT_RATIO_min": 0.8390133122859201, "num__CC_AMT_PAYMENT_CURRENT_min": NaN, "num__CC_NAME_CONTRACT_STATUS_Approved": NaN, "num__PREV_NAME_CLIENT_TYPE_Refreshed": -0.3827878706371788, "num__AMT_REQ_CREDIT_BUREAU_HOUR": NaN, "num__BUREAU_DAYS_CREDIT_mean": NaN, "num__PREV_NAME_GOODS_CATEGORY_Jewelry": 0.15027517211361752, "num__CC_CNT_DRAWINGS_ATM_CURRENT_min": NaN, "num__PREV_WEEKDAY_APPR_PROCESS_START_SUNDAY": -0.4475239538210983, "num__INST_PAY_PAYMENT_DELAY_min": 0.4611855541242847, "num__BUREAU_CREDIT_TYPE_Loan for purchase of shares (margin lending)": NaN, "num__PREV_NAME_GOODS_CATEGORY_Auto Accessories": NaN, "num__CC_SK_DPD_max": NaN, "num__PREV_NAME_GOODS_CATEGORY_Weapon": 0.23674011214082938, "num__PREV_PRODUCT_COMBINATION_POS mobile without interest": NaN, "num__FLOORSMAX_AVG": NaN, "num__PREV_NAME_SELLER_INDUSTRY_Connectivity": -0.6052875606002944, "num__PREV_CHANNEL_TYPE_AP+ (Cash loan)": NaN, "num__PREV_NAME_PAYMENT_TYPE_Cashless from the account of the employer": NaN, "num__PREV_NAME_PAYMENT_TYPE_Non-cash from your account": NaN, "num__PREV_PRODUCT_COMBINATION_POS industry with interest": NaN, "num__PREV_DAYS_FIRST_DUE_min": 0.9493321521647358, "num__PREV_NAME_GOODS_CATEGORY_Office Appliances": NaN, "num__CC_PAYMENT_RATIO_min": NaN, "num__PREV_DAYS_LAST_DUE_mean": -0.7198278834489952, "num__PREV_CNT_PAYMENT_max": -1.0904290279773525, "num__AMT_REQ_CREDIT_BUREAU_DAY": NaN, "num__PREV_NAME_CONTRACT_STATUS_Unused offer": NaN, "num__CC_CNT_DRAWINGS_OTHER_CURRENT_min": NaN, "num__BUREAU_AMT_CREDIT_SUM_DEBT_max": NaN, "num__PREV_NAME_CASH_LOAN_PURPOSE_Purchase of electronic equipment": NaN, "num__INST_PAY_DAYS_ENTRY_PAYMENT_mean": 0.5699765324676597, "num__YEARS_BUILD_MEDI": NaN, "num__CC_AMT_INST_MIN_REGULARITY_min": NaN, "num__BUREAU_AMT_ANNUITY_mean": NaN, "num__PREV_PRODUCT_COMBINATION_Cash X-Sell: high": NaN, "num__PREV_NAME_CASH_LOAN_PURPOSE_Furniture": 0.23674011214082938, "num__PREV_NAME_CASH_LOAN_PURPOSE_Everyday expenses": NaN, "num__EXT_SOURCE_1": NaN, "num__PREV_NAME_CASH_LOAN_PURPOSE_Repairs": -0.011181832125731341, "num__BUREAU_CREDIT_TYPE_Another type of loan": NaN, "num__AMT_REQ_CREDIT_BUREAU_MON": NaN, "num__INST_PAY_AMT_PAYMENT_mean": 0.6667604082181515, "num__BUREAU_AMT_CREDIT_SUM_LIMIT_mean": NaN, "num__BUREAU_CNT_CREDIT_PROLONG_max": NaN, "num__EXT_SOURCE_2": 0.18635883048910665, "num__PREV_CODE_REJECT_REASON_NUNIQUE": -0.4071137435878747, "num__PREV_NAME_CASH_LOAN_PURPOSE_Refusal to name the goal": NaN, "num__BUREAU_CREDIT_CURRENCY_NUNIQUE": NaN, "num__PREV_NAME_SELLER_INDUSTRY_NUNIQUE": -0.7962897800370944, "num__DAYS_BIRTH": -0.632745067040964, "num__BUREAU_STATUS_2": NaN, "num__CC_AMT_DRAWINGS_CURRENT_max": NaN, "num__PREV_NAME_SELLER_INDUSTRY_Auto technology": NaN, "num__BUREAU_MONTHS_BALANCE_max": NaN, "num__PREV_NFLAG_LAST_APPL_IN_DAY_min": 0.259748288078599, "num__PREV_NAME_GOODS_CATEGORY_Gardening": 0.23674011214082938, "num__PREV_NAME_GOODS_CATEGORY_Tourism": 0.23674011214082938, "num__PREV_CODE_REJECT_REASON_SYSTEM": 0.23674011214082938, "num__EXT_SOURCE_3": NaN, "num__BUREAU_DAYS_CREDIT_ENDDATE_max": NaN, "num__PREV_CODE_REJECT_REASON_SCOFR": 0.11470893834562734, "num__PREV_NAME_CASH_LOAN_PURPOSE_Urgent needs": NaN, "num__BUREAU_CREDIT_TYPE_Mortgage": NaN, "num__CC_MONTHS_BALANCE_max": NaN, "num__CC_CNT_DRAWINGS_CURRENT_min": NaN, "num__PREV_NAME_CONTRACT_STATUS_Refused": -0.45595660297325513, "num__PREV_AMT_APPLICATION_min": 1.0175870716692557, "num__BUREAU_AMT_CREDIT_SUM_OVERDUE_sum": NaN, "num__PREV_PRODUCT_COMBINATION_Cash Street: low": NaN, "num__POS_NAME_CONTRACT_STATUS_Amortized debt": NaN, "num__PREV_WEEKDAY_APPR_PROCESS_START_THURSDAY": -0.5404849729843089, "num__BUREAU_DAYS_CREDIT_max": NaN, "num__PREV_NAME_GOODS_CATEGORY_Animals": 0.23674011214082938, "num__BUREAU_DAYS_CREDIT_min": NaN, "num__BUREAU_CREDIT_TYPE_Unknown type of loan": NaN, "num__PREV_WEEKDAY_APPR_PROCESS_START_TUESDAY": -0.5345334423520008, "num__PREV_NAME_YIELD_GROUP_XNA": -0.6596112844653592, "num__POS_CNT_INSTALMENT_min": -0.6006532234752897, "num__BUREAU_CREDIT_TYPE_Loan for business development": NaN, "num__PREV_NAME_CASH_LOAN_PURPOSE_Other": 0.07150749889237479, "num__PREV_NAME_GOODS_CATEGORY_Additional Service": NaN, "num__PREV_NAME_GOODS_CATEGORY_Homewares": 0.16118193934744243, "num__PREV_NAME_SELLER_INDUSTRY_MLM partners": NaN, "num__CC_AMT_DRAWINGS_ATM_CURRENT_mean": NaN, "num__PREV_NAME_SELLER_INDUSTRY_Industry": 0.021021354907596653, "num__CC_AMT_CREDIT_LIMIT_ACTUAL_max": NaN, "num__PREV_PRODUCT_COMBINATION_POS industry without interest": NaN, "num__CC_AMT_CREDIT_LIMIT_ACTUAL_sum": NaN, "num__PREV_NAME_CASH_LOAN_PURPOSE_Education": 0.23674011214082938, "num__AMT_REQ_CREDIT_BUREAU_QRT": NaN, "num__ELEVATORS_AVG": NaN, "num__PREV_NAME_CASH_LOAN_PURPOSE_Gasification / water supply": NaN, "num__BUREAU_CREDIT_TYPE_Interbank credit": NaN, "num__PREV_CODE_REJECT_REASON_SCO": -0.08807108686928901, "num__PREV_CODE_REJECT_REASON_LIMIT": -0.15768736026049368, "num__POS_SK_DPD_mean": -0.12990345133470965, "num__PREV_CHANNEL_TYPE_Channel of corporate sales": NaN, "num__PREV_NAME_YIELD_GROUP_low_action": 1.282653886577299, "num__CC_CNT_DRAWINGS_CURRENT_max": NaN, "num__PREV_AMT_ANNUITY_mean": 1.622528652751951, "num__BUREAU_CREDIT_ACTIVE_Sold": NaN, "num__CC_AMT_DRAWINGS_POS_CURRENT_min": NaN, "num__PREV_RATE_DOWN_PAYMENT_sum": -0.34513267560548105, "num__PREV_HOUR_APPR_PROCESS_START_mean": 0.5066874000698924, "num__PREV_NAME_GOODS_CATEGORY_Medical Supplies": NaN, "num__PREV_WEEKDAY_APPR_PROCESS_START_SATURDAY": -0.5416053649351005, "num__POS_SK_DPD_DEF_max": -0.2724897502657947, "num__BUREAU_AMT_CREDIT_SUM_LIMIT_sum": NaN, "num__BUREAU_STATUS_NUNIQUE": NaN, "num__PREV_NAME_CASH_LOAN_PURPOSE_Building a house or an annex": NaN, "num__PREV_NAME_TYPE_SUITE_Children": -0.07625689471754812, "num__PREV_RATE_INTEREST_PRIMARY_max": NaN, "num__CNT_CHILDREN": -0.5863795809586744, "num__DAYS_EMPLOYED": -0.45356714510232166, "num__PREV_NAME_PAYMENT_TYPE_NUNIQUE": -0.612331993609979, "num__POS_CNT_INSTALMENT_FUTURE_min": -0.19959725060545777, "num__CC_NAME_CONTRACT_STATUS_Completed": NaN, "num__PREV_NAME_GOODS_CATEGORY_Clothing and Accessories": NaN, "num__NONLIVINGAPARTMENTS_AVG": NaN, "num__BUREAU_CREDIT_CURRENCY_currency 3": NaN, "num__PREV_CODE_REJECT_REASON_XNA": 0.16394552472377638, "num__INST_PAY_PAYMENT_RATIO_mean": 0.2181887734334084, "num__DEF_30_CNT_SOCIAL_CIRCLE": -0.32670098415423837, "num__PREV_PRODUCT_COMBINATION_Cash Street: high": NaN, "num__PREV_DAYS_LAST_DUE_min": -0.2603972711482273, "num__BUREAU_AMT_CREDIT_MAX_OVERDUE_max": NaN, "num__AMT_INCOME_TOTAL": -0.375148208983288, "num__BUREAU_CREDIT_ACTIVE_Bad debt": NaN, "num__PREV_NAME_CASH_LOAN_PURPOSE_Car repairs": NaN, "num__CC_UTILIZATION_min": NaN, "num__PREV_NAME_TYPE_SUITE_Spouse, partner": NaN, "num__PREV_FLAG_LAST_APPL_PER_CONTRACT_N": 0.14089011653921485, "num__PREV_CHANNEL_TYPE_Regional / Local": NaN, "num__BUREAU_CREDIT_TYPE_Cash loan (non-earmarked)": NaN, "num__POS_NAME_CONTRACT_STATUS_Returned to the store": NaN, "num__BUREAU_AMT_CREDIT_SUM_sum": NaN, "num__REGION_POPULATION_RELATIVE": 0.7128068806627592, "num__PREV_NAME_CASH_LOAN_PURPOSE_Hobby": 0.23674011214082938, "num__PREV_CHANNEL_TYPE_Car dealer": NaN, "num__BUREAU_CREDIT_TYPE_Loan for working capital replenishment": NaN, "num__COMMONAREA_MEDI": NaN, "num__PREV_NAME_PRODUCT_TYPE_NUNIQUE": -0.6415424048081523, "num__REGION_RATING_CLIENT_W_CITY": -0.06166364133019225, "num__PREV_DAYS_FIRST_DRAWING_mean": 0.43470262162241274, "num__PREV_NAME_GOODS_CATEGORY_Fitness": 0.23674011214082938, "num__INST_PAY_PAYMENT_DELAY_mean": -1.147344306855905, "num__HOUR_APPR_PROCESS_START": -0.020278640676557318, "num__PREV_NAME_TYPE_SUITE_Other_B": 0.03582307224427864, "num__CC_PAYMENT_RATIO_max": NaN, "num__POS_NAME_CONTRACT_STATUS_NUNIQUE": 0.08224581318201546, "num__PREV_NAME_CASH_LOAN_PURPOSE_Business development": NaN, "num__PREV_NAME_TYPE_SUITE_Other_A": 0.11335841664997003, "num__PREV_NAME_GOODS_CATEGORY_Education": 0.23674011214082938, "num__PREV_PRODUCT_COMBINATION_Cash Street: middle": NaN, "num__PREV_NAME_CLIENT_TYPE_NUNIQUE": -0.7879934039334827, "num__PREV_NAME_TYPE_SUITE_Group of people": NaN, "num__BUREAU_CREDIT_CURRENCY_currency 4": NaN, "num__PREV_NAME_GOODS_CATEGORY_Insurance": 0.23674011214082938, "num__PREV_CHANNEL_TYPE_Contact center": NaN, "num__INST_PAY_PAYMENT_DELAY_max": -0.645260250451878, "num__PREV_CNT_PAYMENT_min": -0.3395116474889719, "num__BUREAU_DAYS_CREDIT_ENDDATE_sum": NaN, "num__PREV_NAME_CASH_LOAN_PURPOSE_Buying a used car": NaN, "card_faible__NAME_CONTRACT_TYPE_Cash loans": 1.0, "card_faible__NAME_CONTRACT_TYPE_Revolving loans": 0.0, "card_faible__CODE_GENDER_F": 1.0, "card_faible__CODE_GENDER_M": 0.0, "card_faible__CODE_GENDER_XNA": 0.0, "card_faible__FLAG_OWN_CAR_N": 1.0, "card_faible__FLAG_OWN_CAR_Y": 0.0, "card_faible__FLAG_OWN_REALTY_N": 0.0, "card_faible__FLAG_OWN_REALTY_Y": 1.0, "card_faible__NAME_TYPE_SUITE_Children": 0.0, "card_faible__NAME_TYPE_SUITE_Family": 0.0, "card_faible__NAME_TYPE_SUITE_Group of people": 0.0, "card_faible__NAME_TYPE_SUITE_MISSING": 0.0, "card_faible__NAME_TYPE_SUITE_Other_A": 0.0, "card_faible__NAME_TYPE_SUITE_Other_B": 0.0, "card_faible__NAME_TYPE_SUITE_Spouse, partner": 0.0, "card_faible__NAME_TYPE_SUITE_Unaccompanied": 1.0, "card_faible__NAME_INCOME_TYPE_Businessman": 0.0, "card_faible__NAME_INCOME_TYPE_Commercial associate": 0.0, "card_faible__NAME_INCOME_TYPE_Maternity leave": 0.0, "card_faible__NAME_INCOME_TYPE_Pensioner": 0.0, "card_faible__NAME_INCOME_TYPE_State servant": 0.0, "card_faible__NAME_INCOME_TYPE_Student": 0.0, "card_faible__NAME_INCOME_TYPE_Unemployed": 0.0, "card_faible__NAME_INCOME_TYPE_Working": 1.0, "card_faible__NAME_EDUCATION_TYPE_Academic degree": 0.0, "card_faible__NAME_EDUCATION_TYPE_Higher education": 0.0, "card_faible__NAME_EDUCATION_TYPE_Incomplete higher": 0.0, "card_faible__NAME_EDUCATION_TYPE_Lower secondary": 0.0, "card_faible__NAME_EDUCATION_TYPE_Secondary / secondary special": 1.0, "card_faible__NAME_FAMILY_STATUS_Civil marriage": 0.0, "card_faible__NAME_FAMILY_STATUS_Married": 1.0, "card_faible__NAME_FAMILY_STATUS_Separated": 0.0, "card_faible__NAME_FAMILY_STATUS_Single / not married": 0.0, "card_faible__NAME_FAMILY_STATUS_Unknown": 0.0, "card_faible__NAME_FAMILY_STATUS_Widow": 0.0, "card_faible__NAME_HOUSING_TYPE_Co-op apartment": 0.0, "card_faible__NAME_HOUSING_TYPE_House / apartment": 1.0, "card_faible__NAME_HOUSING_TYPE_Municipal apartment": 0.0, "card_faible__NAME_HOUSING_TYPE_Office apartment": 0.0, "card_faible__NAME_HOUSING_TYPE_Rented apartment": 0.0, "card_faible__NAME_HOUSING_TYPE_With parents": 0.0, "card_faible__WEEKDAY_APPR_PROCESS_START_FRIDAY": 0.0, "card_faible__WEEKDAY_APPR_PROCESS_START_MONDAY": 1.0, "card_faible__WEEKDAY_APPR_PROCESS_START_SATURDAY": 0.0, "card_faible__WEEKDAY_APPR_PROCESS_START_SUNDAY": 0.0, "card_faible__WEEKDAY_APPR_PROCESS_START_THURSDAY": 0.0, "card_faible__WEEKDAY_APPR_PROCESS_START_TUESDAY": 0.0, "card_faible__WEEKDAY_APPR_PROCESS_START_WEDNESDAY": 0.0, "card_faible__FONDKAPREMONT_MODE_MISSING": 0.0, "card_faible__FONDKAPREMONT_MODE_not specified": 0.0, "card_faible__FONDKAPREMONT_MODE_org spec account": 0.0, "card_faible__FONDKAPREMONT_MODE_reg oper account": 0.0, "card_faible__FONDKAPREMONT_MODE_reg oper spec account": 0.0, "card_faible__HOUSETYPE_MODE_MISSING": 0.0, "card_faible__HOUSETYPE_MODE_block of flats": 0.0, "card_faible__HOUSETYPE_MODE_specific housing": 0.0, "card_faible__HOUSETYPE_MODE_terraced house": 0.0, "card_faible__WALLSMATERIAL_MODE_Block": 0.0, "card_faible__WALLSMATERIAL_MODE_MISSING": 0.0, "card_faible__WALLSMATERIAL_MODE_Mixed": 0.0, "card_faible__WALLSMATERIAL_MODE_Monolithic": 0.0, "card_faible__WALLSMATERIAL_MODE_Others": 0.0, "card_faible__WALLSMATERIAL_MODE_Panel": 0.0, "card_faible__WALLSMATERIAL_MODE_Stone, brick": 0.0, "card_faible__WALLSMATERIAL_MODE_Wooden": 0.0, "card_faible__EMERGENCYSTATE_MODE_MISSING": 0.0, "card_faible__EMERGENCYSTATE_MODE_No": 0.0, "card_faible__EMERGENCYSTATE_MODE_Yes": 0.0, "card_eleve__OCCUPATION_TYPE": 0.0955362603415121, "card_eleve__ORGANIZATION_TYPE": 0.10279429787111831, "bool__FLAG_MOBIL": 1.0, "bool__FLAG_EMP_PHONE": 1.0, "bool__FLAG_WORK_PHONE": 0.0, "bool__FLAG_CONT_MOBILE": 1.0, "bool__FLAG_PHONE": 0.0, "bool__FLAG_EMAIL": 0.0, "bool__REG_REGION_NOT_LIVE_REGION": 0.0, "bool__REG_REGION_NOT_WORK_REGION": 0.0, "bool__LIVE_REGION_NOT_WORK_REGION": 0.0, "bool__REG_CITY_NOT_LIVE_CITY": 0.0, "bool__REG_CITY_NOT_WORK_CITY": 0.0, "bool__LIVE_CITY_NOT_WORK_CITY": 0.0, "bool__FLAG_DOCUMENT_2": 0.0, "bool__FLAG_DOCUMENT_3": 1.0, "bool__FLAG_DOCUMENT_4": 0.0, "bool__FLAG_DOCUMENT_5": 0.0, "bool__FLAG_DOCUMENT_6": 0.0, "bool__FLAG_DOCUMENT_7": 0.0, "bool__FLAG_DOCUMENT_8": 0.0, "bool__FLAG_DOCUMENT_9": 0.0, "bool__FLAG_DOCUMENT_10": 0.0, "bool__FLAG_DOCUMENT_11": 0.0, "bool__FLAG_DOCUMENT_12": 0.0, "bool__FLAG_DOCUMENT_13": 0.0, "bool__FLAG_DOCUMENT_14": 0.0, "bool__FLAG_DOCUMENT_15": 0.0, "bool__FLAG_DOCUMENT_16": 0.0, "bool__FLAG_DOCUMENT_17": 0.0, "bool__FLAG_DOCUMENT_18": 0.0, "bool__FLAG_DOCUMENT_19": 0.0, "bool__FLAG_DOCUMENT_20": 0.0, "bool__FLAG_DOCUMENT_21": 0.0}, "score": 0.16228976845741272, "decision": "ACCORD\u00c9", "threshold": 0.5, "cpu_percent": 0.0, "ram_percent": 77.5, "system_load": 0.05, "num_threads": 21}
439
+ {"request_id": "bf367fa7-4fd2-4600-90d1-1408e389f104", "timestamp": 1781365536.823392, "path": "/predict", "method": "POST", "status": "success", "error_message": null, "latency_ms": 237.7948760986328, "request_size_bytes": 13081, "response_size_bytes": 0, "cpu_percent": 42.4, "ram_percent": 77.5, "system_load": 0.05, "num_threads": 21}
logs/predictions_log.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7e00cd3d60db94620ea7c63f0012056f2a8b139c97b2dd240145e939f3d11321
3
- size 440050
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d77dd4f506cc2f902c3b53415a6e8616ee2e647e2a7722ad2ab2de185986f1e
3
+ size 440495
logs/predictions_log_batch.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e0fca745fa6c30a9f1052790064c64b4e9507910eef837041fd7857201e13173
3
- size 7205
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4a3290ee28732a177d6f0e5e2e134f718fabab6a9e15f0ca9d84c0f6b4138aec
3
+ size 7221
poetry.lock CHANGED
The diff for this file is too large to render. See raw diff
 
pyproject.toml CHANGED
@@ -27,11 +27,19 @@ dependencies = [
27
  "python-dotenv ==1.2.1",
28
  "psycopg2-binary ==2.9.11",
29
  "pytest-cov ==7.0.0",
30
- "gradio==5.0.0",
31
  "requests (>=2.34.2,<3.0.0)",
32
- "evidently (>=0.7.21,<0.8.0)"
 
 
 
 
 
 
33
  ]
34
 
 
 
35
 
36
  [build-system]
37
  requires = ["poetry-core>=2.0.0,<3.0.0"]
 
27
  "python-dotenv ==1.2.1",
28
  "psycopg2-binary ==2.9.11",
29
  "pytest-cov ==7.0.0",
30
+ "gradio==4.44.0",
31
  "requests (>=2.34.2,<3.0.0)",
32
+ "evidently==0.4.25",
33
+ "streamlit==1.29.0",
34
+ "jupyter==1.0.0",
35
+ "notebook==6.5.5",
36
+ "jupyter-client==7.4.9",
37
+ "jupyter-core==5.5.0",
38
+ "ipykernel==6.25.2"
39
  ]
40
 
41
+ [tool.poetry]
42
+ package-mode = false
43
 
44
  [build-system]
45
  requires = ["poetry-core>=2.0.0,<3.0.0"]