Spaces:
Sleeping
Sleeping
File size: 778 Bytes
2fb4316 ef6f991 2fb4316 b4e6713 2fb4316 |
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 |
# from fastapi import FastAPI
# import joblib
# import numpy as np
# app = FastAPI()
# model = joblib.load("model/model.pkl")
# @app.post("/predict/")
# def predict(features: list):
# prediction = model.predict([np.array(features)])
# return {"prediction": prediction.tolist()}
from fastapi import FastAPI
from pydantic import BaseModel
import joblib
import numpy as np
app = FastAPI()
model = joblib.load("model/model.pkl")
print("Classes:", model.classes_)
# new comment from github 2
class InputData(BaseModel):
features: list[float] # Ensures 'features' is a required list of floats
#changes
@app.post("/predict/")
def predict(data: InputData):
prediction = model.predict([np.array(data.features)])
return {"prediction": prediction.tolist()}
|