ml4genomics commited on
Commit
eb3491c
·
verified ·
1 Parent(s): 4356d04

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +37 -0
  2. model.pkl +3 -0
  3. requirements.txt +68 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ import joblib
3
+ import numpy as np
4
+ from pydantic import BaseModel
5
+
6
+ app = FastAPI()
7
+
8
+ # Load the model (ensure this path is correct)
9
+ model = joblib.load("model.pkl")
10
+
11
+ # Pydantic model for input validation
12
+ class InputData(BaseModel):
13
+ BMI: float
14
+ Parity: int
15
+ Gravida: int
16
+ Glucoselevel0minblood: float
17
+ Glucoselevel120minblood: float
18
+ SystolicBloodPressureCuff: float
19
+ DiastolicBloodPressure: float
20
+
21
+ @app.get("/")
22
+ def home():
23
+ return {"message": "ML API Running"}
24
+
25
+ @app.post("/predict")
26
+ def predict(data: InputData):
27
+ # Convert the data to a numpy array for prediction
28
+ input_array = np.array([[data.BMI, data.Parity, data.Gravida, data.Glucoselevel0minblood,
29
+ data.Glucoselevel120minblood, data.SystolicBloodPressureCuff,
30
+ data.DiastolicBloodPressure]])
31
+
32
+ # Perform prediction and get probabilities
33
+ prediction = model.predict(input_array)
34
+ prob = model.predict_proba(input_array)[:, 1] # Probability for the positive class (1)
35
+
36
+ # Return both prediction and probability
37
+ return {"prediction": int(prediction[0]), "probability": prob[0] * 100}
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4d4dd1dffa54ef3f22c9cd1382984ebf3cb181b6106e0051867287bd35bc53bd
3
+ size 1953
requirements.txt ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ altair==6.0.0
2
+ annotated-doc==0.0.4
3
+ annotated-types==0.7.0
4
+ anyio==4.12.1
5
+ attrs==25.4.0
6
+ blinker==1.9.0
7
+ cachetools==6.2.6
8
+ certifi==2026.1.4
9
+ charset-normalizer==3.4.4
10
+ click==8.3.1
11
+ cloudpickle==3.1.2
12
+ colorama==0.4.6
13
+ contourpy==1.3.3
14
+ cycler==0.12.1
15
+ et_xmlfile==2.0.0
16
+ fastapi==0.129.0
17
+ fonttools==4.61.1
18
+ gitdb==4.0.12
19
+ GitPython==3.1.46
20
+ h11==0.16.0
21
+ idna==3.11
22
+ Jinja2==3.1.6
23
+ joblib==1.5.3
24
+ jsonschema==4.26.0
25
+ jsonschema-specifications==2025.9.1
26
+ kiwisolver==1.4.9
27
+ llvmlite==0.46.0
28
+ MarkupSafe==3.0.3
29
+ matplotlib==3.10.8
30
+ narwhals==2.16.0
31
+ numba==0.64.0
32
+ numpy==2.4.2
33
+ openpyxl==3.1.5
34
+ packaging==26.0
35
+ pandas==2.3.3
36
+ pillow==12.1.1
37
+ protobuf==6.33.5
38
+ pyarrow==23.0.1
39
+ pydantic==2.12.5
40
+ pydantic_core==2.41.5
41
+ pydeck==0.9.1
42
+ pyparsing==3.3.2
43
+ python-dateutil==2.9.0.post0
44
+ python-multipart==0.0.22
45
+ pytz==2025.2
46
+ referencing==0.37.0
47
+ requests==2.32.5
48
+ rpds-py==0.30.0
49
+ scikit-learn==1.8.0
50
+ scipy==1.17.0
51
+ shap==0.50.0
52
+ six==1.17.0
53
+ slicer==0.0.8
54
+ smmap==5.0.2
55
+ starlette==0.52.1
56
+ streamlit==1.54.0
57
+ tenacity==9.1.4
58
+ threadpoolctl==3.6.0
59
+ toml==0.10.2
60
+ tornado==6.5.4
61
+ tqdm==4.67.3
62
+ typing-inspection==0.4.2
63
+ typing_extensions==4.15.0
64
+ tzdata==2025.3
65
+ unicorn==2.1.4
66
+ urllib3==2.6.3
67
+ uvicorn==0.41.0
68
+ watchdog==6.0.0