Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -73,7 +73,7 @@ def load_models():
|
|
| 73 |
@app.post("/forecast", response_model=ForecastResponse)
|
| 74 |
def forecast(req: ForecastRequest):
|
| 75 |
if not req.transactions:
|
| 76 |
-
raise HTTPException(
|
| 77 |
|
| 78 |
df = pd.DataFrame([t.dict() for t in req.transactions])
|
| 79 |
|
|
@@ -87,9 +87,7 @@ def forecast(req: ForecastRequest):
|
|
| 87 |
exp_fc = fit_and_forecast(exp, steps, freq, method=method)
|
| 88 |
|
| 89 |
return ForecastResponse(
|
| 90 |
-
period_end=[
|
| 91 |
-
d.strftime("%Y-%m-%d") for d in inc_fc.index.to_pydatetime().tolist()
|
| 92 |
-
],
|
| 93 |
income_forecast=[float(x) for x in inc_fc.values.tolist()],
|
| 94 |
expense_forecast=[float(x) for x in exp_fc.values.tolist()],
|
| 95 |
)
|
|
|
|
| 73 |
@app.post("/forecast", response_model=ForecastResponse)
|
| 74 |
def forecast(req: ForecastRequest):
|
| 75 |
if not req.transactions:
|
| 76 |
+
raise HTTPException(400, "transactions is empty")
|
| 77 |
|
| 78 |
df = pd.DataFrame([t.dict() for t in req.transactions])
|
| 79 |
|
|
|
|
| 87 |
exp_fc = fit_and_forecast(exp, steps, freq, method=method)
|
| 88 |
|
| 89 |
return ForecastResponse(
|
| 90 |
+
period_end=[d.strftime("%Y-%m-%d") for d in inc_fc.index.to_pydatetime().tolist()],
|
|
|
|
|
|
|
| 91 |
income_forecast=[float(x) for x in inc_fc.values.tolist()],
|
| 92 |
expense_forecast=[float(x) for x in exp_fc.values.tolist()],
|
| 93 |
)
|