DevZoneX's picture
Upload linear regression model
05a1079
raw
history blame contribute delete
457 Bytes
from fastapi import FastAPI
import joblib
import numpy as np
# Load your model
model = joblib.load("linear_regression_model.joblib")
app = FastAPI()
@app.post("/predict")
def predict(input_data: list):
# Convert input to numpy array and reshape if necessary
input_array = np.array(input_data).reshape(1, -1) # Adjust the shape based on your model's input
prediction = model.predict(input_array)
return {"prediction": prediction.tolist()}