GodfreyOwino commited on
Commit
1bb18f1
·
verified ·
1 Parent(s): f6f771d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ import joblib
3
+ import pandas as pd
4
+
5
+ app = FastAPI()
6
+
7
+ model = joblib.load('ModelV2.joblib')
8
+
9
+ @app.post("/predict")
10
+ async def predict(data: dict):
11
+ df = pd.DataFrame([data])
12
+ prediction = model.predict(df)
13
+ return {"prediction": prediction.tolist()}
14
+
15
+ @app.get("/")
16
+ async def root():
17
+ return {"message": "NPK Needs Prediction API"}