Update main.py
Browse files
main.py
CHANGED
|
@@ -110,7 +110,7 @@ def predict_revenue():
|
|
| 110 |
for doc in query:
|
| 111 |
transaction = doc.to_dict()
|
| 112 |
data.append({
|
| 113 |
-
"date": transaction["date"],
|
| 114 |
"amountDue": transaction["amountDue"]
|
| 115 |
})
|
| 116 |
|
|
@@ -143,10 +143,11 @@ def predict_revenue():
|
|
| 143 |
|
| 144 |
# Extract the forecast for the requested interval
|
| 145 |
forecast_data = forecast[['ds', 'yhat']].tail(interval)
|
| 146 |
-
predictions =
|
| 147 |
|
| 148 |
# Return predictions in JSON format
|
| 149 |
return jsonify({"predictedData": predictions})
|
| 150 |
|
|
|
|
| 151 |
if __name__ == "__main__":
|
| 152 |
app.run(debug=True, host="0.0.0.0", port=7860)
|
|
|
|
| 110 |
for doc in query:
|
| 111 |
transaction = doc.to_dict()
|
| 112 |
data.append({
|
| 113 |
+
"date": transaction["date"],
|
| 114 |
"amountDue": transaction["amountDue"]
|
| 115 |
})
|
| 116 |
|
|
|
|
| 143 |
|
| 144 |
# Extract the forecast for the requested interval
|
| 145 |
forecast_data = forecast[['ds', 'yhat']].tail(interval)
|
| 146 |
+
predictions = [{"date": row['ds'].strftime('%Y-%m-%d'), "value": row['yhat']} for _, row in forecast_data.iterrows()]
|
| 147 |
|
| 148 |
# Return predictions in JSON format
|
| 149 |
return jsonify({"predictedData": predictions})
|
| 150 |
|
| 151 |
+
|
| 152 |
if __name__ == "__main__":
|
| 153 |
app.run(debug=True, host="0.0.0.0", port=7860)
|