forked from iam-veeramalla/first-mlops-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
25 lines (21 loc) · 624 Bytes
/
main.py
File metadata and controls
25 lines (21 loc) · 624 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# main.py
from fastapi import FastAPI
from pydantic import BaseModel
import joblib
import numpy as np
app = FastAPI()
model = joblib.load("diabetes_model.pkl")
class DiabetesInput(BaseModel):
Pregnancies: int
Glucose: float
BloodPressure: float
BMI: float
Age: int
@app.get("/")
def read_root():
return {"message": "Diabetes Prediction API is live"}
@app.post("/predict")
def predict(data: DiabetesInput):
input_data = np.array([[data.Pregnancies, data.Glucose, data.BloodPressure, data.BMI, data.Age]])
prediction = model.predict(input_data)[0]
return {"diabetic": bool(prediction)}