Abhilash7 commited on
Commit
f28c171
·
verified ·
1 Parent(s): db32a25

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, Request
2
+ from prophet import Prophet
3
+ import pandas as pd
4
+
5
+ app = FastAPI()
6
+
7
+ # Load the historical data CSV file
8
+ df = pd.read_csv("Queue_Historical_Data_Jan_to_May_2025.csv")
9
+
10
+ # Initialize the Prophet model
11
+ model = Prophet()
12
+
13
+ # Fit the model with historical data
14
+ model.fit(df)
15
+
16
+ @app.post("/run")
17
+ async def forecast(request: Request):
18
+ # Create a future dataframe for the next 7 days
19
+ future = model.make_future_dataframe(df, periods=7)
20
+
21
+ # Predict the future values
22
+ forecast = model.predict(future)
23
+
24
+ # Return the last 7 predicted values
25
+ return forecast[['ds', 'yhat']].tail(7).to_dict(orient="records")