NIIHAAD commited on
Commit
7f675d3
·
1 Parent(s): d8e953f

updtae app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -376,13 +376,14 @@ def preprocess_sound(df):
376
 
377
 
378
 
379
- def xgb_predict_safe(model, X, feature_names, label_encoder=None):
380
- # sécurité ultime
381
- X = X[feature_names].astype(np.float32)
382
-
 
383
  dmatrix = xgb.DMatrix(
384
- X.values,
385
- feature_names=feature_names
386
  )
387
 
388
  pred = model.get_booster().predict(dmatrix)[0]
@@ -556,7 +557,7 @@ def predict_with_metadata(url):
556
 
557
 
558
 
559
- return raw_str + processed_str + prediction_str
560
 
561
 
562
 
 
376
 
377
 
378
 
379
+ def xgb_predict_safe(model, X, label_encoder=None):
380
+ # Sécurité ultime : forcer exactement les features du booster
381
+ booster_features = model.get_booster().feature_names
382
+ X_safe = X.reindex(columns=booster_features, fill_value=0.0).astype(np.float32)
383
+
384
  dmatrix = xgb.DMatrix(
385
+ X_safe.values,
386
+ feature_names=booster_features
387
  )
388
 
389
  pred = model.get_booster().predict(dmatrix)[0]
 
557
 
558
 
559
 
560
+ return 'rien à afficher'
561
 
562
 
563