Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|