yoursdvniel commited on
Commit
49d9f84
·
verified ·
1 Parent(s): 14e4adc

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -2
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"], # Assuming transaction["date"] is already a datetime object
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 = forecast_data['yhat'].tolist()
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)