File size: 879 Bytes
a70bc70
 
 
 
 
 
 
40c64a4
a70bc70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from fastapi import FastAPI, HTTPException
import joblib
import pandas as pd
from pydantic import BaseModel

pipeline=joblib.load('model/pipeline.joblib')
encoder= joblib.load('model/encoder.joblib')




app=FastAPI(
    title="Seppsis Classification FASTAPI"
)


class SepsisFeatures(BaseModel):
    PRG: int
    PL: int
    PR: int
    SK: int
    TS: int
    M11: float
    BD2: float
    Age: int
    Insurance: int
    
    

    
@app.get('/')
def home():
    return { "FASTAPI to classify sepssis" }

@app.get('/info')
def info():
    return 'App info page'


@app.post('/predict')
def predict_sepssi(sepsis_features:SepsisFeatures):

    df = pd.DataFrame([sepsis_features.model_dump()])
    
    prediction =pipeline.predict(df)
    
    ecoded_prediction= encoder.inverse_transform([prediction])[0]
    
    pred ={"prediction": ecoded_prediction }
    return pred