Abubakari commited on
Commit
5b17d15
โ€ข
1 Parent(s): c89fe88

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +16 -10
main.py CHANGED
@@ -6,24 +6,18 @@ import numpy as np
6
  import os
7
 
8
  app = FastAPI()
9
- #app.mount("/static", StaticFiles(directory="static"), name="static")
10
- #templates = Jinja2Templates(directory="templates")
11
 
12
  def load_model():
13
- cwd = os.getcwd()
14
- destination = os.path.join(cwd, "Assets")
 
15
 
16
- imputer_filepath = os.path.join(destination, "numerical_imputer.joblib")
17
- scaler_filepath = os.path.join(destination, "scaler.joblib")
18
- model_filepath = os.path.join(destination, "lr_model.joblib")
19
-
20
- num_imputer = joblib.load(imputer_filepath)
21
  scaler = joblib.load(scaler_filepath)
22
  model = joblib.load(model_filepath)
23
 
24
  return num_imputer, scaler, model
25
 
26
-
27
  def preprocess_input_data(input_data, num_imputer, scaler):
28
  input_data_df = pd.DataFrame([input_data])
29
  num_columns = [col for col in input_data_df.columns if input_data_df[col].dtype != 'object']
@@ -33,8 +27,20 @@ def preprocess_input_data(input_data, num_imputer, scaler):
33
 
34
  @app.get("/")
35
  def read_root():
 
 
 
 
 
 
 
 
 
 
 
36
  return "Sepsis Prediction App"
37
 
 
38
  @app.get("/sepsis/predict")
39
  def predict_sepsis_endpoint(PRG: float, PL: float, PR: float, SK: float, TS: float,
40
  M11: float, BD2: float, Age: float, Insurance: int):
 
6
  import os
7
 
8
  app = FastAPI()
 
 
9
 
10
  def load_model():
11
+ num_imputer_filepath = "numerical_imputer.joblib"
12
+ scaler_filepath = "scaler.joblib"
13
+ model_filepath = "lr_model.joblib"
14
 
15
+ num_imputer = joblib.load(num_imputer_filepath)
 
 
 
 
16
  scaler = joblib.load(scaler_filepath)
17
  model = joblib.load(model_filepath)
18
 
19
  return num_imputer, scaler, model
20
 
 
21
  def preprocess_input_data(input_data, num_imputer, scaler):
22
  input_data_df = pd.DataFrame([input_data])
23
  num_columns = [col for col in input_data_df.columns if input_data_df[col].dtype != 'object']
 
27
 
28
  @app.get("/")
29
  def read_root():
30
+ """
31
+ Welcome to the Sepsis Prediction API! ๐Ÿฉบ๐Ÿ’‰
32
+
33
+ This API provides advanced machine learning predictions for sepsis. โšก๐Ÿ“Š
34
+
35
+ For more information and to explore the API's capabilities,
36
+ please visit the documentation: [API Documentation](https://abubakari-sepsis-fastapi-prediction-app.hf.space/docs/) ๐Ÿ“š๐Ÿ”
37
+
38
+ Stay proactive in detecting sepsis with our predictive tool! ๐Ÿš€๐Ÿ”ฎ
39
+
40
+ """
41
  return "Sepsis Prediction App"
42
 
43
+
44
  @app.get("/sepsis/predict")
45
  def predict_sepsis_endpoint(PRG: float, PL: float, PR: float, SK: float, TS: float,
46
  M11: float, BD2: float, Age: float, Insurance: int):