Delete model/inference.py
Browse files- model/inference.py +0 -25
model/inference.py
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
import pickle
|
2 |
-
import numpy as np
|
3 |
-
from fastapi import FastAPI
|
4 |
-
from pydantic import BaseModel
|
5 |
-
|
6 |
-
# Load the model (ensure this path matches the location of your model)
|
7 |
-
with open("expense_forecaster_model.pkl", "rb") as model_file:
|
8 |
-
model = pickle.load(model_file)
|
9 |
-
|
10 |
-
# Initialize the FastAPI app
|
11 |
-
app = FastAPI()
|
12 |
-
|
13 |
-
class ForecastRequest(BaseModel):
|
14 |
-
month: float # The input feature (number of months)
|
15 |
-
|
16 |
-
class ForecastResponse(BaseModel):
|
17 |
-
predicted_expense: float
|
18 |
-
|
19 |
-
@app.post("/predict", response_model=ForecastResponse)
|
20 |
-
async def predict_expense(request: ForecastRequest):
|
21 |
-
# Predict the expense for the given month
|
22 |
-
predicted_expense = model.predict(np.array([[request.month]]))[0]
|
23 |
-
return ForecastResponse(predicted_expense=predicted_expense)
|
24 |
-
|
25 |
-
inference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|