tamizh1296 commited on
Commit
fcecdce
·
verified ·
1 Parent(s): b736356

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +4 -9
app.py CHANGED
@@ -58,18 +58,13 @@ def predict_total_sales_batch():
58
  file = request.files['file']
59
  input_data = pd.read_csv(file)
60
 
61
- # Predict log sales using full pipeline
62
- predicted_log_sales = model.predict(input_data).tolist()
63
-
64
- # Convert log sales to actual sales
65
- predicted_sales = np.exp(predicted_log_sales)
66
- predicted_sales = [round(float(s), 2) for s in predicted_sales]
67
 
68
  return jsonify({'Predicted Sales for Each Row': predicted_sales})
69
 
70
- # Create a dictionary of predictions with property IDs as keys
71
- property_ids = input_data['id'].tolist() # Assuming 'id' is the property ID column
72
- output_dict = dict(zip(Product_Id, predicted_sales)) # Use actual sales total
73
 
74
  # Return the predictions dictionary as a JSON response
75
  return output_dict
 
58
  file = request.files['file']
59
  input_data = pd.read_csv(file)
60
 
61
+ # Make predictions for the batch data and convert raw predictions into a readable format
62
+ predicted_sales = [x for x in model.predict(input_data.drop("Product_Id",axis=1)).tolist()]
 
 
 
 
63
 
64
  return jsonify({'Predicted Sales for Each Row': predicted_sales})
65
 
66
+ product_id = input_data.Product_Id.values.tolist()
67
+ output_dict = dict(zip(product_id, predicted_sales))
 
68
 
69
  # Return the predictions dictionary as a JSON response
70
  return output_dict