-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
27 lines (22 loc) · 771 Bytes
/
main.py
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
import fastapi
from fastapi import FastAPI
import pickle
from pydantic import BaseModel
import numpy as np
app = FastAPI()
model = pickle.load(open('rfr_model.pkl','rb'))
class UserInput(BaseModel):
temperature: float
exhaust_vacuum: float
amb_pressure: float
r_humidity: float
@app.get("/")
def read_root():
return{"Hello": "World"}
@app.post('/predict')
async def predict(UserInput: UserInput):
prediction = model.predict(np.array([UserInput.temperature,
UserInput.exhaust_vacuum,
UserInput.amb_pressure,
UserInput.r_humidity]).reshape(1, -1))
return{'prediction': prediction.tolist()}