-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
44 lines (36 loc) · 1.27 KB
/
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from typing import List
import uvicorn
from fastapi import FastAPI, status
from columns import WineQualityData
from predict import predict_wine_quality
app = FastAPI(
title="Wine Quality Prediction",
description="An example project for running a prediction using a machine learning model stored within a GCP bucket",
contact={
"name": "Kwame Mintah",
"url": "https://github.com/kwame-mintah/kwame-mintah/discussions/categories/general",
"email": "[email protected]",
},
license_info={
"name": "GNU GENERAL PUBLIC LICENSE",
"url": "https://www.gnu.org/licenses/gpl-3.0.en.html#license-text",
},
)
@app.post(
path="/predict/",
operation_id="winePrediction",
summary="Predict wine quality",
response_model=List[float],
status_code=status.HTTP_200_OK,
)
async def predict(data: List[WineQualityData]) -> List[float]:
"""
Predict the quality of wine based on quantitative features
like the wines “fixed acidity”, “pH”, “residual sugar”, and so on.
:param data: list of different wine qualities
:return:
"""
return predict_wine_quality(wine_list=data)
if __name__ == "__main__":
# Useful when running application locally.
uvicorn.run(app, host="0.0.0.0", port=8000)