Parthi07 commited on
Commit
6ff6e6e
·
verified ·
1 Parent(s): c460be3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -45,9 +45,7 @@ def predict_product_sales():
45
  input_data = pd.DataFrame([sample])
46
 
47
  # Make prediction (get product_store_sales_price)
48
- predicted_sales_price = model.predict(input_data)[0]
49
-
50
- predicted_sales_price = round(float(predicted_sales_price), 2)
51
 
52
  return jsonify({'Predicted Product Sales Price':predicted_sales_price})
53
 
@@ -65,12 +63,13 @@ def predict_product_sales_batch():
65
  input_data = pd.read_csv(file)
66
  # Make predictions for all properties in the DataFrame (get prodict_sales)
67
  predicted_product_sales = model.predict(input_data).tolist()
 
68
  # Create a dictionary of predictions with product IDs as keys
69
  product_ids=input_data['Product_Id'].tolist()
70
  output_dict=dict(zip(product_ids,predicted_product_sales))
71
 
72
  # Return the predictions dictionary as a JSON response
73
- return output_dict
74
 
75
  # Run the Flask application in debug mode if this script is executed directly
76
  if __name__ == "__main__":
 
45
  input_data = pd.DataFrame([sample])
46
 
47
  # Make prediction (get product_store_sales_price)
48
+ predicted_sales_price = round(float(model.predict(input_data)[0]),2)
 
 
49
 
50
  return jsonify({'Predicted Product Sales Price':predicted_sales_price})
51
 
 
63
  input_data = pd.read_csv(file)
64
  # Make predictions for all properties in the DataFrame (get prodict_sales)
65
  predicted_product_sales = model.predict(input_data).tolist()
66
+ predicted_product_sales = [round(float(p),2) for p in predicted_product_sales]
67
  # Create a dictionary of predictions with product IDs as keys
68
  product_ids=input_data['Product_Id'].tolist()
69
  output_dict=dict(zip(product_ids,predicted_product_sales))
70
 
71
  # Return the predictions dictionary as a JSON response
72
+ return jsonify(output_dict)
73
 
74
  # Run the Flask application in debug mode if this script is executed directly
75
  if __name__ == "__main__":