etorqweku commited on
Commit
a70bc70
·
1 Parent(s): d960ab4

Add application file

Browse files
Files changed (4) hide show
  1. main.py +52 -0
  2. model/encoder.joblib +3 -0
  3. model/pipeline.joblib +3 -0
  4. requirement.txt +0 -0
main.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, HTTPException
2
+ import joblib
3
+ import pandas as pd
4
+ from pydantic import BaseModel
5
+
6
+ pipeline=joblib.load('model/pipeline.joblib')
7
+ encoder= joblib.load('model/encoder.joblib')
8
+ print(pipeline)
9
+ print(encoder)
10
+
11
+
12
+
13
+ app=FastAPI(
14
+ title="Seppsis Classification FASTAPI"
15
+ )
16
+
17
+
18
+ class SepsisFeatures(BaseModel):
19
+ PRG: int
20
+ PL: int
21
+ PR: int
22
+ SK: int
23
+ TS: int
24
+ M11: float
25
+ BD2: float
26
+ Age: int
27
+ Insurance: int
28
+
29
+
30
+
31
+
32
+ @app.get('/')
33
+ def home():
34
+ return { "FASTAPI to classify sepssis" }
35
+
36
+ @app.get('/info')
37
+ def info():
38
+ return 'App info page'
39
+
40
+
41
+ @app.post('/predict')
42
+ def predict_sepssi(sepsis_features:SepsisFeatures):
43
+
44
+ df = pd.DataFrame([sepsis_features.model_dump()])
45
+
46
+ prediction =pipeline.predict(df)
47
+
48
+ ecoded_prediction= encoder.inverse_transform([prediction])[0]
49
+
50
+ pred ={"prediction": ecoded_prediction }
51
+ return pred
52
+
model/encoder.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2bc345aaf664510eb9b1712f068fd88fef085c7d24fbbb6bb07a8af513247291
3
+ size 542
model/pipeline.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e5ee28da33a2fe86c2f697cd009efa9566eeab4ebcce09e9f00c3551f2042973
3
+ size 1267887
requirement.txt ADDED
Binary file (4.43 kB). View file