Spaces:
Running
Running
Create app.py
Browse files
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"}
|