mobile_predictor / main.py
Mahmoud7's picture
Upload 4 files
ff5c136
raw
history blame contribute delete
868 Bytes
# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
import uvicorn
from fastapi import FastAPI
from pydantic import BaseModel
import pickle
import pandas as pd
app = FastAPI()
class scoring_item(BaseModel):
battery_power: float
px_height: float
px_width: float
ram: float
with open("model.pkl", "rb") as f:
model = pickle.load(f)
@app.post('/predict')
def scoring_endpoint(item:scoring_item):
df = pd.DataFrame([item.dict().values()], columns=item.dict().keys())
ypred = model.predict(df)
return int(ypred)
"""@app.get('/Welcome')
def get_name(name: str):
return {'Brace yourself, ': f'{name}'}"""
"""if __name__ == '__main__':
uvicorn.run(app, host='127.0.0.1',port=8000)"""