Mekam commited on
Commit
970ef03
·
1 Parent(s): 29418c1

feat(prediction): correct dict

Browse files
src/controllers/prediction_controller.py CHANGED
@@ -78,9 +78,17 @@ def global_prediction_on_csv(file: UploadFile):
78
 
79
  # Chargement du modèle
80
  try:
81
- model = joblib.load("src/models/L1_Logistic_v0.joblib")
 
 
 
 
82
  except FileNotFoundError:
83
  raise HTTPException(status_code=500, detail="Modèle 'L1_Logistic_v0.joblib' introuvable")
 
 
 
 
84
 
85
  print("drop label column if exists")
86
 
@@ -92,6 +100,12 @@ def global_prediction_on_csv(file: UploadFile):
92
 
93
  print("features prepared, starting prediction")
94
 
 
 
 
 
 
 
95
  # Prédictions
96
  preds = model.predict(X)
97
 
 
78
 
79
  # Chargement du modèle
80
  try:
81
+ saved = joblib.load("src/models/L1_Logistic_v0.joblib")
82
+ model = saved["model"]
83
+ scaler = saved["scaler"]
84
+ pca = saved.get("pca", None)
85
+ # features = saved["features"]
86
  except FileNotFoundError:
87
  raise HTTPException(status_code=500, detail="Modèle 'L1_Logistic_v0.joblib' introuvable")
88
+ # try:
89
+ # model = joblib.load("src/models/L1_Logistic_v0.joblib")
90
+ # except FileNotFoundError:
91
+ # raise HTTPException(status_code=500, detail="Modèle 'L1_Logistic_v0.joblib' introuvable")
92
 
93
  print("drop label column if exists")
94
 
 
100
 
101
  print("features prepared, starting prediction")
102
 
103
+ # Standardisation
104
+ X = scaler.transform(X)
105
+
106
+ # PCA si utilisé
107
+ if pca is not None:
108
+ X = pca.transform(X)
109
  # Prédictions
110
  preds = model.predict(X)
111