Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| import pickle | |
| import numpy as np | |
| app = FastAPI() | |
| # Load model at startup | |
| with open("app/model.pkl", "rb") as f: | |
| model = pickle.load(f) | |
| # Input schema | |
| class InputData(BaseModel): | |
| features: list[float] | |
| def home(): | |
| return {"message": "Logistic Regression API is up!"} | |
| def predict(data: InputData): | |
| prediction = model.predict([np.array(data.features)]) | |
| return {"prediction": int(prediction[0])} | |