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] @app.get("/") def home(): return {"message": "Logistic Regression API is up!"} @app.post("/predict") def predict(data: InputData): prediction = model.predict([np.array(data.features)]) return {"prediction": int(prediction[0])}