Created
September 23, 2022 13:25
-
-
Save sahasourav17/6caf09cf24131861626bb915d6ce7e72 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Union | |
import uvicorn | |
import numpy as np | |
import pandas as pd | |
import pickle as pk | |
from sklearn.linear_model import LogisticRegression | |
from fastapi import FastAPI | |
from pydantic import BaseModel | |
app = FastAPI() | |
class ScoringItem(BaseModel): | |
qs1: int | |
qs2: int | |
qs3: int | |
qs4: int | |
qs5: int | |
qs6: int | |
qs7: int | |
qs8: int | |
with open('mlmodel.pkl','rb') as f: | |
model = pk.load(f) | |
@app.post("/") | |
async def func(item:ScoringItem): | |
X_new = np.array([list(item.dict().values())]) | |
yhat = model.predict(X_new)[0] | |
return {"prediction":str(yhat)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment