DhanashreeP commited on
Commit
2142780
ยท
verified ยท
1 Parent(s): 4137480

๐Ÿš€ Upload Flask + Docker backend files

Browse files
Files changed (1) hide show
  1. SuperKart_Sales_Predictor.py +5 -4
SuperKart_Sales_Predictor.py CHANGED
@@ -24,7 +24,7 @@ def predict_sales():
24
  """
25
  data = request.get_json()
26
 
27
- # You must ensure these keys match your modelโ€™s training features
28
  sample = {
29
  'Product_Weight': data['Product_Weight'],
30
  'Product_Allocated_Area': data['Product_Allocated_Area'],
@@ -39,11 +39,12 @@ def predict_sales():
39
 
40
  input_df = pd.DataFrame([sample])
41
 
42
- # Ensure encoding matches model training (e.g., one-hot or label encoding)
43
- # This assumes you used label encoding in preprocessing before model training
44
-
45
  # Predict
46
  predicted_sales = model.predict(input_df)[0]
 
 
 
 
47
  predicted_sales = round(float(predicted_sales), 2)
48
 
49
  print("๐Ÿš€ Flask app is starting...")
 
24
  """
25
  data = request.get_json()
26
 
27
+ # Extract relevant features from the JSON data
28
  sample = {
29
  'Product_Weight': data['Product_Weight'],
30
  'Product_Allocated_Area': data['Product_Allocated_Area'],
 
39
 
40
  input_df = pd.DataFrame([sample])
41
 
 
 
 
42
  # Predict
43
  predicted_sales = model.predict(input_df)[0]
44
+
45
+ # Calculate actual price
46
+ predicted_sales = np.exp(predicted_sales)
47
+
48
  predicted_sales = round(float(predicted_sales), 2)
49
 
50
  print("๐Ÿš€ Flask app is starting...")