Upload linear regression model
Browse files
app.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
import joblib
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
# Load your model
|
| 6 |
+
model = joblib.load("linear_regression_model.joblib")
|
| 7 |
+
|
| 8 |
+
app = FastAPI()
|
| 9 |
+
|
| 10 |
+
@app.post("/predict")
|
| 11 |
+
def predict(input_data: list):
|
| 12 |
+
# Convert input to numpy array and reshape if necessary
|
| 13 |
+
input_array = np.array(input_data).reshape(1, -1) # Adjust the shape based on your model's input
|
| 14 |
+
prediction = model.predict(input_array)
|
| 15 |
+
return {"prediction": prediction.tolist()}
|