Sonny4Sonnix commited on
Commit
56271c1
·
1 Parent(s): d7c7b20

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +30 -3
main.py CHANGED
@@ -22,18 +22,45 @@ class InputFeatures(BaseModel):
22
  bd2: float
23
  age: int
24
 
 
 
 
 
 
 
 
 
 
25
  # Load the pickled XGBoost model
26
  model_input = joblib.load("model_1.joblib")
27
 
28
- @app.post("/sepsis_prediction")
29
- async def predicts(input:model_input):
 
 
 
 
 
 
 
 
30
 
31
  XGB= Pipeline([
32
  ("col_trans", full_pipeline),
33
  ("feature_selection", SelectKBest(score_func=f_classif, k='all')),
34
  ("model", BaggingClassifier(base_estimator=XGBClassifier(random_state=42)))
35
  ])
36
- return prediction
 
 
 
 
 
 
 
 
 
 
37
 
38
 
39
 
 
22
  bd2: float
23
  age: int
24
 
25
+ # Plasma glucose:float
26
+ # Blood Work Result 1:float
27
+ # Blood Pressure :float
28
+ # Blood Work Result 2:float
29
+ # Blood Work Result 3:float
30
+ # Body mass index :float
31
+ # Blood Work Result 4:float
32
+ # patients age :int
33
+
34
  # Load the pickled XGBoost model
35
  model_input = joblib.load("model_1.joblib")
36
 
37
+
38
+ @app.post("/sepsis_prediction")
39
+ async def predict(
40
+ input:model_input
41
+ ):
42
+ #Numeric Features
43
+
44
+ num_features = [['Plasma glucose','Blood Work Result-1','Blood Pressure,
45
+ 'Blood Work Result-2',' Blood Work Result-3', 'Body mass index,
46
+ 'Blood Work Result-4', 'Age']]
47
 
48
  XGB= Pipeline([
49
  ("col_trans", full_pipeline),
50
  ("feature_selection", SelectKBest(score_func=f_classif, k='all')),
51
  ("model", BaggingClassifier(base_estimator=XGBClassifier(random_state=42)))
52
  ])
53
+
54
+ #print(model_input)
55
+ df = pd.DataFrame([input])
56
+ final_input = np.array(predict_input.fit_transform(df), dtype = np.str)
57
+ prediction = model.predict(np.array([[final_input]]).reshape(1, 1))
58
+
59
+ return prediction
60
+
61
+ if __name__ == '__main__':
62
+ uvicorn.run("Main:app", reload = True)
63
+
64
 
65
 
66