Enoch1359 commited on
Commit
8a6669e
·
verified ·
1 Parent(s): 5ab5f11

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -7
app.py CHANGED
@@ -29,13 +29,28 @@ def sale_pred_single():
29
 
30
  @super_kart_api.post('/v1/spkart_batch')
31
  def sale_pred_batch():
32
- file=request.files['file']
33
- input_data=pd.read_csv(file)
34
- predicted_sale=model.predict(input_data).tolist()
35
- predicted_sales=[round(float(i))for i in predicted_sale]
36
- sale_outlets=input_data['Store_Id'].tolist()
37
- response=dict(zip(sale_outlets,predicted_sales))
38
- return jsonify(response)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  if __name__=='__main__':
40
  super_kart_api.run()
41
 
 
29
 
30
  @super_kart_api.post('/v1/spkart_batch')
31
  def sale_pred_batch():
32
+ file = request.files['file']
33
+ print("File Received:", file.filename)
34
+
35
+ # Read input data
36
+ input_data = pd.read_csv(file)
37
+ print("Input Data Shape:", input_data.shape)
38
+ print(input_data.head())
39
+
40
+ # Make predictions
41
+ predicted_sale = model.predict(input_data).tolist()
42
+ print("Predicted Sales Length:", len(predicted_sale))
43
+
44
+ predicted_sales = [round(float(i)) for i in predicted_sale]
45
+ sale_outlets = input_data['Store_Id'].tolist()
46
+ print("Sale Outlets Length:", len(sale_outlets))
47
+
48
+ # Create response
49
+ response = dict(zip(sale_outlets, predicted_sales))
50
+ print("Response:", response)
51
+
52
+ return jsonify(response)
53
+
54
  if __name__=='__main__':
55
  super_kart_api.run()
56