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

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -48,11 +48,8 @@ def predict_total_sales():
48
  # 🚨 Use original feature names here as used during training
49
  input_data = pd.DataFrame([sample])
50
 
51
- # Predict log sales using full pipeline (preprocessing + model)
52
- predicted_log_sales = model.predict(input_data)[0]
53
-
54
  # Convert log sales to actual sales
55
- predicted_sale = round(float(np.exp(predicted_log_sales)), 2)
56
 
57
  return jsonify({'Predicted Product Store Sales Total': predicted_sale})
58
 
@@ -62,7 +59,7 @@ def predict_total_sales_batch():
62
  input_data = pd.read_csv(file)
63
 
64
  # Predict log sales using full pipeline
65
- predicted_log_sales = model.predict(input_data)
66
 
67
  # Convert log sales to actual sales
68
  predicted_sales = np.exp(predicted_log_sales)
@@ -70,6 +67,13 @@ def predict_total_sales_batch():
70
 
71
  return jsonify({'Predicted Sales for Each Row': predicted_sales})
72
 
 
 
 
 
 
 
 
73
 
74
  # Run the Flask application in debug mode if this script is executed directly
75
  if __name__ == '__main__':
 
48
  # 🚨 Use original feature names here as used during training
49
  input_data = pd.DataFrame([sample])
50
 
 
 
 
51
  # Convert log sales to actual sales
52
+ predicted_sale = round(model.predict(input_data).tolist()[0], 2)
53
 
54
  return jsonify({'Predicted Product Store Sales Total': predicted_sale})
55
 
 
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)
 
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
76
+
77
 
78
  # Run the Flask application in debug mode if this script is executed directly
79
  if __name__ == '__main__':