| from fastapi import FastAPI | |
| import joblib | |
| import numpy as np | |
| # Load your model | |
| model = joblib.load("linear_regression_model.joblib") | |
| app = FastAPI() | |
| 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()} |