Commit
·
511a161
1
Parent(s):
67ca5ef
Update main.py
Browse files
main.py
CHANGED
@@ -10,8 +10,7 @@ from pydantic import BaseModel # Import Pydantic's BaseModel
|
|
10 |
app = FastAPI()
|
11 |
templates = Jinja2Templates(directory="templates")
|
12 |
|
13 |
-
|
14 |
-
xgb_model = joblib.load("model.joblib")
|
15 |
|
16 |
class InputFeatures(BaseModel):
|
17 |
prg: float
|
@@ -23,15 +22,19 @@ class InputFeatures(BaseModel):
|
|
23 |
bd2: float
|
24 |
age: int
|
25 |
|
|
|
|
|
|
|
|
|
26 |
@app.get("/")
|
27 |
async def read_root():
|
28 |
-
return {"message": "Welcome to the
|
29 |
|
30 |
@app.get("/form/")
|
31 |
async def show_form():
|
32 |
|
33 |
@app.post("/predict/")
|
34 |
-
async def
|
35 |
request: Request,
|
36 |
input_data: InputFeatures # Use the Pydantic model for input validation
|
37 |
):
|
|
|
10 |
app = FastAPI()
|
11 |
templates = Jinja2Templates(directory="templates")
|
12 |
|
13 |
+
|
|
|
14 |
|
15 |
class InputFeatures(BaseModel):
|
16 |
prg: float
|
|
|
22 |
bd2: float
|
23 |
age: int
|
24 |
|
25 |
+
# Load the pickled XGBoost model
|
26 |
+
xgb_model = joblib.load("model.joblib")
|
27 |
+
|
28 |
+
|
29 |
@app.get("/")
|
30 |
async def read_root():
|
31 |
+
return {"message": "Welcome to the Sepsis Prediction API"}
|
32 |
|
33 |
@app.get("/form/")
|
34 |
async def show_form():
|
35 |
|
36 |
@app.post("/predict/")
|
37 |
+
async def predict_sepsis(
|
38 |
request: Request,
|
39 |
input_data: InputFeatures # Use the Pydantic model for input validation
|
40 |
):
|